brgdotnet
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" );
}
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/
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.