Handle Error Customerrors
Contents |
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn more about Stack Overflow the company Business Learn more about hiring asp.net mvc custom error page developers or posting ads with us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask asp.net mvc error handling Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just like you, helping each other. Join asp.net error handling them; it only takes a minute: Sign up How can I make the HandleError attribute work without web.config setting (customErrors)? up vote 1 down vote favorite I can't get [HandleError] attribute in MVC 5 to work. I have this asp.net custom error page Controller [HandleError] public class HomeController : Controller { public ActionResult WelcomePage() { throw new Exception("Oops!"); return View(); } } Which gives the yellow screen of death. If I add in the web.config
Asp.net Error Logging
handleerror share|improve this question asked Jun 29 '15 at 12:54 radbyx 3,10483976 add a comment| 1 Answer 1 active oldest votes up vote 1 down vote accepted The HandleError filter handle exceptions only if the customErrors is turned on in web.config see this link for more details: http://www.prideparrot.com/blog/archive/2012/5/exception_handling_in_asp_net_mvc share|improve this answer answered Jun 29 '15 at 12:57 Ala 1,0151523 So do people add the HandleError attribute or not? I mean.. I still get to the error page, without the [HandleError]. I would expect to get something extra but I might be wrong? –radbyx Jun 29 '15 at 13:00 1 Oh okay I think I get it now. I have to set 'customErrors' to On, as you documented. And the reason why it works without [HandleError] is by design. But if I wanted to specify it like "[HandleError(Exception = typeof(DbException), View = "DatabaseError")]" I have to write the attribute. –radbyx Jun 29 '15 at 13:09 1 HandleError filter will handle errors that occurs in the controller level. There is another way to handle controller errors other than using HandleError filter which is to override a function on the controller which is called (OnException). –Ala Jun 29 '15 at 13:11 1 Thanks it works great! –radbyx Jun 29 '15 at 13:16 Glad to help :) –Ala Jun 29 '15 at 13:17 add a comment| Your Answer draft saved
here for a quick overview of the site Help Center Detailed answers to any questions you might have
Asp.net Error Handling Best Practices
Meta Discuss the workings and policies of this site About Us custom error page in asp.net example Learn more about Stack Overflow the company Business Learn more about hiring developers or posting ads with application_error mvc us Stack Overflow Questions Jobs Documentation Tags Users Badges Ask Question x Dismiss Join the Stack Overflow Community Stack Overflow is a community of 4.7 million programmers, just http://stackoverflow.com/questions/31116287/how-can-i-make-the-handleerror-attribute-work-without-web-config-setting-custom like you, helping each other. Join them; it only takes a minute: Sign up MVC HandleError vs customErrors tag up vote 2 down vote favorite So if I understand [HandleError] correctly (see here) you have to add it to each Controller that you want to have errors handled on. It seems much easier to just add http://stackoverflow.com/questions/3874278/mvc-handleerror-vs-customerrors-tag the path of your error page into the web.config customErrors tag:
here for a quick overview of the site Help Center Detailed answers to any questions you might have Meta Discuss the workings and policies of this site About Us Learn http://programmers.stackexchange.com/questions/45195/what-are-the-definitive-guidelines-for-custom-error-handling-in-asp-net-mvc-3 more about Stack Overflow the company Business Learn more about hiring developers or posting ads with us Programmers Questions Tags Users Badges Unanswered Ask Question _ Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The custom error best answers are voted up and rise to the top What are the definitive guidelines for custom Error Handling in ASP.NET MVC 3? up vote 43 down vote favorite 16 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 custom error page 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: Display debugging information in dev Display friendly error page in production Log errors and email them to administrator in production Return 500 HTTP Status Code For 404 Not Found errors: Display friendly error page Log errors and email them to administrator in production Return 404 HTTP Status Code Is there a way to meet these goals with ASP.NET MVC? asp.net asp.net-mvc error-handling asp.net-mvc-3 share|improve this question asked Jan 21 '11 at 20:07 RyanW 5491410 migrated from stackoverflow.com Feb 7 '11 at 22:08 This question came from our site for professional and enthusiast programmers. 2 I'd like this question to be migrated BACK to SO so it can get more answers. I'm seeking coded answers. –Shawn Mclean May 13 '11 at 17:21 @Shawn That's unlikely to happen. The question is more on topic here than it is on SO and it has an accepted answer. Questions also generally