I am trying to make a custom HTTP 404 error page when someone types in a URL that doesn't invoke a valid action or controller in ASP.NET MVC, instead of it displaying the generic "Resource Not Found" ASP.NET error.
I don't want to use the web.config to handle this.
Is there any kind of routing magic I can do to catch any invalid URLs?
Update: I tried the answer given, however I still get the ugly "Resource Not Found" message.
Another update: Ok, apparently something changed in RC1. I've even tried specifically trapping 404 on an HttpException
and it still just gives me the "Resource Not Found" page.
I've even used MvcContrib's resource's feature and nothing - same problem. Any ideas?
Just add catch all route at the end of the routes table and display whatever page you want with it.
See: How can i make a catch all route to handle '404 page not found' queries for ASP.NET MVC?