By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
432,247 Members | 871 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 432,247 IT Pros & Developers. It's quick & easy.

Control.Unload exception handling

P: n/a
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)
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
Nov 18 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.