Link to home
Start Free TrialLog in
Avatar of brgdotnet
brgdotnetFlag for United States of America

asked on

Catching an exception in the Application_Error method.

I am looking for some good expert help on this question. I noticed that in the Global.asax file I have a method named Application_Error.
It is listed below. So it appears that we can catch all exceptions by using the Server.GetLastError() message. If that is the case, then why do we even need try catch blocks throughout the application? Couldn't we just use the Application_Error method to catch all of the exceptions?

void Application_Error(object sender, EventArgs e)
{
   Exception errorCaught = Server.GetLastError();
   Response.Redirect("~/Home/ErrorPage");

}
ASKER CERTIFIED SOLUTION
Avatar of Miguel Oz
Miguel Oz
Flag of Australia image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial