What is the `Application_Error` method in `Global.asax` and how is it used for custom error pages?

Question

Grade: Education Subject: Support
What is the `Application_Error` method in `Global.asax` and how is it used for custom error pages?
Asked by:
98 Viewed 98 Answers

Answer (98)

Best Answer
(415)
`Application_Error` is an event handler in `Global.asax` that is triggered when an unhandled exception occurs within your ASP.NET MVC application. Inside this method, you can perform actions like logging the error, clearing sensitive data, and redirecting the user to a custom error page. It's the central point for global exception handling and is often used in conjunction with `web.config` error configuration.