Control.Unload exception handling

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
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Error with server 3
Exception Handling 33
Exception handling 53
Handling exceptions in WCF 5
Problem with Upload Error handling 3
How to catch this exception 3
School Project 1
asp.net worker process locking files 3

Members online

Forum statistics

Threads
473,995
Messages
2,570,228
Members
46,817
Latest member
AdalbertoT

Latest Threads

Top