How can I Handler 404 errors without the framework throwing an Exception 500 error code?
Tell me more
×
Stack Overflow is a question and answer site for
professional and enthusiast programmers. It's 100% free, no registration required.
http://jason.whitehorn.ws/2008/06/17/Friendly-404-Errors-In-ASPNET-MVC.aspx gives the following explanation: Add a wildcard routing rule as your final rule:
Any request that doesn't match another rule gets routed to the Http404 action of the Error controller, which you also need to configure:
|
|||||||||||||||||||
|
You can also override HandleUnknownAction within your controller in the cases where a request does match a controller, but doesn't match an action. The default implementation does raise a 404 error. |
|||
|
With MVC 3 you can return HttpNotFound() to properly return a 404. Like this:
|
|||
|