Help please, custom 404 error

B

Bubu

Hello this is robert,
I need some suggestion,
I have a website, hosted in windows 2003 server,shared hosting.
I would like to have a custom 404 error page, for missing files.
In the help file of my internet provider they said to do it in .NET,
like this

web.config

<configuration>
<system.web>
<customErrors mode="On" defaultRedirect="error.aspx">
<error statusCode="404" redirect="404.aspx" />
</customErrors>
</system.web>
</configuration>

but i would like to use it also for

missing .html
missing directories
missing .asp


Any Help ?


Thanks.

Robert.
 
M

Mark Fitzpatrick

Robert,
It won't work for files that aren't handled by the ASP.Net process.
IIS itself does allow for custom error pages so your host might be able to
hook this up for you automatically. You could set it up so that ASP.Net
handles these pages too, but of course that's a performance hit to have it
handle extra pages as it's one more step in their processing, and having
them handle .asp pages may not be a good idea either.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage
 
J

j0vo

Missing errors (all 404s) can be easily caught into your aspx file by doing
the following:

For this example, assume your web app is called MyApp and is located in
/inetpub/wwwroot/myapp
and your 404 page is called 404.aspx located in /inetpub/wwwroot/myapp

Your web.config stays as you have it, looks good. This will catch requests
like http://www.myserver.com/myapp/not-here.aspx or any aspx or ascx request

To intercept the missing files, goto the web server and bring up the
properties of the web app (virtual folder). Under the "Custom Errors" tab
select "404" and pick up your file /inetpub/wwwroot/myapp/404.aspx

Now that instructs IIS web server process to use your 404.aspx page for any
404 error... so missing html requests can get picked up for non asp.net
requests (and directs them to your asp.net page!)

There is probably a way to automate this in a setup file. If you don't have
control of the web server you are on, I'm not sure what to do except bribe
the administrators. Good luck

Jovo Filips
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

HTTP Error 404 1
custom error 404 1
404 pages 4
404 best practice 3
Circumventing the 404 error 2
custom error page not redirecting, but showing web.config 0
CustomErrors for a 404 code 2
<customErrors 3

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,188
Latest member
Crypto TaxSoftware

Latest Threads

Top