HttpApplication.Error

Joined
Jan 10, 2007
Messages
43,898
Location
In The Machine
"An ASP.NET help thread from W3bbo? This is madness!"

Yes, I know....

It's been a while since I last did any work in this area in ASP.NET before. So now I'm kinda stuck.

I've got an ASP.NET Web Application, and within my Global.asax superclass I've got defined:

public class Global : HttpApplication {

public Global() {
this.BeginRequest += new EventHandler( Global_BeginRequest );
this.EndRequest += new EventHandler( Global_EndRequest );
this.Error += new EventHandler( Global_Error );
}

protected void Global_Error(object sender, EventArgs e) {

String path = Server.MapPath("~/Exceptions");
String filepath = System.IO.Path.Combine( path, DateTime.Now.ToString("yyyy-MM-dd_HH-mm-ss-fff") );

Request.SaveAs( filepath + ".http", true );

Exception theException = Server.GetLastError();

System.IO.File.WriteAllText( filepath + ".ex", theException.ToString(), System.Text.Encoding.UTF8 );

}

Thing is... Global_Error gets called for stuff like 404s to *.aspx resources, but not when an unhandled exception occurs in my own pages.

For instance, in another page, in the Load event, I throw new Exception("foobar", new Exception("baz")); but the Global_Error method isn't called at all.

Why is this and how can I correct it?


More...

View All Our Microsoft Related Feeds
 
Back
Top