HTTP 404 Redirect does not work

W

wwwmike

For some reasons my HTTP Redirect for 404 errors does not work for
certain files like .gif .jpg
on IIS Version: 5.1, but it works perfectly with the VisualStudio2005
internal webserver

****Web.Config****
.......
<customErrors mode="On" defaultRedirect="http://www.cnn.com">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.aspx" />
</customErrors>
.........
*******************

IIS 5.1
http://localhost/mywebsite/notExisting.gif ( does not work)
http://localhost/mywebsite/notExisting.aspx ( works!! , it also work
with *.html etc)

VisualStudio2005 Internal Server
http://localhost:1768/anonymousspeech/notExisting.gif (Works!!)

I guess I have to do some settings on IIS5.1. What do I have to do in
order to get proper redirects also for image file name like .jpg .gif
etc.

Thanks for helping
 
K

Kevin Jones

i believe, you need to map all the extensions to aspnet_isapi filter.
>
> check out this
> http://aspadvice.com/blogs/bmiller/archive/2004/10/22/2452.aspx for more
> details on the same.

Right - but you may not want to do that as it's only going to slow down
the processing. You can change the default error handling properties in
IIS, although this may not give you exactly what you want.

Go to the properties for the site, find the 'Custom Errors' tab and you
can set a default error page there. Although this will only work (I
believe) if the user has the browser configured to show the error page
when a 404 is returned rather than showing the browsers specific 404
message. I'm not sure if you can configure IIS to redirect to a page
when you get a 404 error, hopefully somebody else can answer that,

Kevin
 
W

wwwmike

Thanks Kevin,

The 404 redirect helped. Any file not found is redirected to an ASPX
page.

On the ASPX page I get the entire querystring (context.request.rawurl).
Then I check if the filename.

This way, I dont need to use any handlers and execution speed does not
decrease for each request.

Luckely my provider set up the 404 redirect on IIS, which you need
since ASP.NET only processes aspx pages but not .gif files.

Thanks

Mike :)
 

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


Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top