G
Guest
I am running into a issue catching a thrown error in the Control.Unload event. Is it possible to throw an Application error from the Unload event and have the global.asax Application_Error catch it? Here is a code sample, this is in my PageBase.cs
private void InitializeComponent()
{
this.Unload += new System.EventHandler(this.Page_UnLoad);
this.Load += new System.EventHandler(this.Page_Load);
this.PreRender += new System.EventHandler(this.Pre_Render);
}
private void Page_UnLoad(object sender, System.EventArgs e)
{
try
{
objSession.Save(); // throws an error in my BLL
}
catch(Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
So what happens is my BLL throws an error and I can see the error being caught in the try-catch. But the weird thing is it then goes to the objSession.Save() and continues on. It won't get thrown to my global.asax.cs page.
protected void Application_Error(Object sender, EventArgs e)
{
// catch error and log it
}
private void InitializeComponent()
{
this.Unload += new System.EventHandler(this.Page_UnLoad);
this.Load += new System.EventHandler(this.Page_Load);
this.PreRender += new System.EventHandler(this.Pre_Render);
}
private void Page_UnLoad(object sender, System.EventArgs e)
{
try
{
objSession.Save(); // throws an error in my BLL
}
catch(Exception ex)
{
throw new ApplicationException(ex.Message);
}
}
So what happens is my BLL throws an error and I can see the error being caught in the try-catch. But the weird thing is it then goes to the objSession.Save() and continues on. It won't get thrown to my global.asax.cs page.
protected void Application_Error(Object sender, EventArgs e)
{
// catch error and log it
}