How do I stop IIS7 from putting out its own 404 before my MVC app gets a chance to handle it?

Posted by Gary McGill on Stack Overflow See other posts from Stack Overflow or by Gary McGill
Published on 2010-04-13T17:20:10Z Indexed on 2010/04/13 17:23 UTC
Read the original article Hit count: 460

Filed under:
|

I have an ASP.NET MVC 2 application, which has an Application_Error event handler in global.asax. In this, I'm detecting the case where the Exception type is HttpException and the HTTP code is 404, and redirecting to my own 404-handling page.

This works fine on my Cassini development server, but now I'm trying to move it over to my production server which has IIS7.

When I request a non-existent URL, IIS7 is showing its own 404 page, and so far as I can tell, my Application_Error method is never called.

How do I fix that?

© Stack Overflow or respective owner

Related posts about iis7

Related posts about asp.net-mvc