ASP.NET: How can I properly redirect requests with 404 errors?

Posted by Adrian Grigore on Stack Overflow See other posts from Stack Overflow or by Adrian Grigore
Published on 2010-03-20T13:48:44Z Indexed on 2010/03/20 14:11 UTC
Read the original article Hit count: 247

Filed under:
|
|

Hi,

I'd like my ASP.NET MVC application to redirect failed requests to matching action methods of a certain controller. This works fine on my development machine running Windows 7, but not on my production machine running Windows 2008 R2.

I set up my web.config as follows:

<customErrors mode="On" defaultRedirect="/Error/ServerError/500">       
            <error statusCode="403" redirect="/Error/AccessDenied" />
            <error statusCode="404" redirect="/Error/FileNotFound" />
</customErrors>

This customErrors section works fine on both of my machines (production and development) for 500 Internal Server errors.

It also works fine for 404 errors on my development machine.

However, it does not properly redirect 404 errors on the production machine. Instead of /Error/FileNotFound, I get the standard 404 page that comes with IIS 7.

What could be the problem here?

© Stack Overflow or respective owner

Related posts about iis

Related posts about ASP.NET