Reputation: 1930
I recently discovered that the IIS worker process in production was crashing 2-3 times per week. I noticed in the exception logs that the its because of an UnhandledException. I investigated and found that the Global.asax had no Server.Transfer call.
I then did some googling and it appears that it's better to use Response.Redirect. Is this true, I keep on getting mixed comments on this...
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
if (null != Context && null != Context.AllErrors)
System.Diagnostics.Debug.WriteLine(Context.AllErrors.Length);
//bool isUnexpectedException = true;
HttpContext context = ((HttpApplication)sender).Context;
Exception ex = context.Server.GetLastError();
if (ex.InnerException != null)
ex = ex.InnerException;
LogManager.ExceptionHandler(ex);
Server.Transfer("GeneralError.aspx");
}
Upvotes: 0
Views: 5255
Reputation: 1733
It depends on if you would want your user to see the "redirection". Personally I would use Response.Redirect for this case.
Check out this answer on the difference between the two: https://stackoverflow.com/a/224577/1260077
Upvotes: 2