What are the definitive guidelines for custom Error Handling in ASP.NET MVC 3?

Posted by RyanW on Programmers See other posts from Programmers or by RyanW
Published on 2011-01-21T20:07:28Z Indexed on 2011/02/07 23:34 UTC
Read the original article Hit count: 618

The process of doing custom error handling in ASP.NET MVC (3 in this case) seems to be incredibly neglected. I've read through the various questions and answers here, on the web, help pages for various tools (like Elmah), but I feel like I've gone in a complete circle and still don't have the best solution. With your help, perhaps we can set a new standard approach for error handling. I'd like to keep things simple and not over-engineer this.

Here are my goals:

For Server errors/exceptions:

  1. Display debugging information in dev
  2. Display friendly error page in production
  3. Log errors and email them to administrator in production
  4. Return 500 HTTP Status Code

For 404 Not Found errors:

  1. Display friendly error page
  2. Log errors and email them to administrator in production
  3. Return 404 HTTP Status Code

Is there a way to meet these goals with ASP.NET MVC?

© Programmers or respective owner

Related posts about ASP.NET

Related posts about asp.net-mvc