Set up your own custom 404 and 500 error pages in an ASP.NET MVC site

Most website visitor appreciates a clean understandable error page, therefor  I have set up custom 404 and 500 pages at my main web site.  These are the steps:

  1. Redirect errors by activating custom errors in web.config in the system.websection.
  2. Remove the error handling filter in Global.asax.cs.
  3. Finally create a controller named Controllers/ErrorController.cs together with related view to handle the action results NotFound and InternalServerError.
  4. Congrats, you now have your own custom error pages! Fill the pages with whatever content you want. I decided to use simple images. Don’t ask me about the car wreck, I was also suprised when I bumped into it on a national park hike.

 errorhandling Set up your own custom  404 and 500 error pages in an ASP.NET MVC site

More creative solutions can be found here.

Leave Reply