I've done a bit of research into HttpHandlers and HttpModules and I'm not clear on the best way to implement this to my specifications.
My issue is that the StaticFile handler handles all urls with extensions and will return a default IIS 404 page instead of visiting the NotFound
action of my ErrorsController
. I want to use MVC to handle all 404s because of the benefits of using .cshtml pages over .html pages along with the fact that I perform logging and of all 404 responses and the pages contain some dynamic content.
I don't want to enable <modules runAllManagedModulesForAllRequests="true">
because of the performance impact it causes and because it seems like the wrong way to do this.
Is it plausible to create an HttpModule and have it check for the existence of the requested file and, if not found, send the request to the managed pipeline and eventually to my ErrorsController
to handle the request?