[RESOLVED] Application_Error in global.asax not firing
Hi,
I'm trying to handle all my application exceptions inside the global.asax but from some reason it's not firing at all, i never tried to do it before so i guess i'm doing something wrong here...
here is the code inside the default.aspx page that throw the error:
Code:
protected void Page_Load(object sender, EventArgs e)
{
throw new Exception();
}
and here is the code inside the global.asax:
Code:
void Application_Error(object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
string err = "Error Caught in Application_Error event\n" +
"Error in: " + Request.Url.ToString() +
"\nError Message:" + objErr.Message.ToString() +
"\nStack Trace:" + objErr.StackTrace.ToString();
EventLog.WriteEntry("Sample_WebApp", err, EventLogEntryType.Error);
Server.ClearError();
Server.Transfer("~/About.aspx");
}
can someone please lead me to the right direction ?
Re: Application_Error in global.asax not firing
Hey,
I can't think or a reason why that wouldn't be firing.
Are you trying this on a brand new site, or an existing one? Might be worth trying it on a new site, and make sure that it works there first.
In case you haven't seen it, there are full details here:
http://www.15seconds.com/issue/030102.htm
Gary
Re: Application_Error in global.asax not firing
hay, motil
did you try to add a break point ?
Re: Application_Error in global.asax not firing
Hi, thanks for the answer! i forgot to update this thread, changing it to this:
Code:
void Application_Error(object sender, EventArgs e)
{
Exception objErr = Server.GetLastError().GetBaseException();
[.... my own implementation goes here ...]
Server.ClearError();
Server.Transfer("~/About.aspx");
}
and implementing my own code (the original code was example from microsoft website) fixed the problem.
Thanks again for the answers!
Re: Application_Error in global.asax not firing
Hey,
Glad to hear that you got it working!
Remember to mark thread resolved :)
Gary
Re: Application_Error in global.asax not firing
Re: [RESOLVED] Application_Error in global.asax not firing