![]() We simply turn on the CustomErrors in the web.config. ![]() ![]() Public static void RegisterGlobalFilters(GlobalFilterCollection filters)īy default, if you turn on CustomErrors, the behavior of the HandleErrorAttribute is to redirect you to the default Error page. The attribute filter is put in place by the default MVC template in the Global.asax (or for MVC4 in the App_Start\FilterConfig.cs) by adding the Action filter as follows: The HandleErrorAttribute() attribute filter will pipe the Unhandled exceptions to this attribute filter enabling you to take appropriate exception. The HandleError attribute helps mark controller classes for ‘Unhandled Error’ exceptions. Goal 4- Manage 404 error with a proper error message Goal 3 - See exception stack traces at debug time Goal 2- See only user friendly messages at Runtime Goal 1 - Use MVCs HandleError action filter to take care of Unhandled/Unexpected errors Overall we try to achieve the following on IIS 7 We will also look at a solution to handle 404 errors gracefully. In this article, we will see how we can use the HandleError attribute to quickly put together an exception handling mechanism that helps hide the ‘dark’ underbelly of your application but helps you debug with the same configuration. If for some unique scenario, ELMAH does not handle your needs, you can fallback on the default HandleError Attribute in MVC. In a previous article, we saw how to use ELMAH for managing unhandled errors in MVC applications.
0 Comments
Leave a Reply. |