I have read a lot about error handling in MVC (specifically about applying a HandleError attribute and about using the Application_Error on the Global.asax). I am interested in gracefully handling the following types of exception:
- Exceptions thrown inside the controller
- Exceptions thrown when performing binding of data in the view.
Currently my application behaves in the following way
- All exceptions thrown in the controller are unhandled. They reach the Application_Error method of the Global.asax
- All exceptions in the view are unhandled and reach the Application_Error method of the Global.asax
- Once in the Application_Error method, I log the exception, decide if the application is run locally or remotely. If so, I present the yellow screen to the user, or perform a Response.Redirect to custom error pages.
This logic works correctly for errors thrown inside controllers that render parent views or the parent view itself. The downside of this logic is that, when an error is thrown inside a Child Action which should render a PartialView the whole page becomes unusable. This because the yellow error screen or the custom error page occupies the complete page and wont allow the user to view the other sections of the webpage.
What I want to do/know is if it is possible to:
- Display the yellow error screen inside of a partial view but render the rest of the page correctly.
- Redirecting the user to a partial view error page that allows for the rest of the page to remain usable.
throw new Exception()line of code anywhere inside your controller action or inside the partial view and see what happens. @JackM I allready have that in place. The global error page is already defined and the user gets redirected to it. So, the entire page is substituted by my custom screen - Luis Becerril