How do I make custom 404 error pages (and other HTTP errors) work with code routing?
My existing project registers a custom filter error handler to handle some error logging and has an Error controller with Actions (and corresponding Views) for the various errors where I want to use customized pages.
In web.config, I have the following...
<customErrors mode="On" defaultRedirect="/Error">
<error statusCode="404" redirect="/Error/NotFound"/>
<error statusCode="403" redirect="/Error/Forbidden"/>
Without MVCCodeRouting configured, this all works like a charm. If someone enters an invalid URL, say /MissingPage or /NonExistingPage.aspx, then my error filter captures the 404, does it's logging, and then displays my custom Error/NotFound page.
However, if I enable MVC Code Routing, only the second example is successfully caught by my filter and displays the Error/NotFound page. The first example, which is missing any standard ASP file extension, simply shows the IIS HTTP Error 404.0 - Not Found page.
My custom filter is never called, Application_Error is never called, and the error page in web.config is never displayed.