Global.asax and Application_End

  • Thread starter Thread starter Craig
  • Start date Start date
C

Craig

Hi,
I'm having difficulty understanding how the Application_End event in the
Global.asax file gets called. I thought that it's called when the specific
web site is stopped via the IIS management console. Could anyone please tell
me where I can dispose of objects when wanting to stop a specific web site
without having to explicitly run IISRESET, as I have other web sites that I
am not allowed to reset on the same machine and calling IISRESET will reset
them.
Thanks you.
Regards,
Craig
 
If the lifetime of the object is that of the application's lifetime, then you don't need to call dispose as the framework will
invoke the finalizers for these objects before the AppDomain is unloaded. In other words, if the app is ending then you don't have
to clean up managed resources. They are managed, and the framework does it for you.

Unless it's a custom object that needs to release unmanaged resources. Then you can do this in the Application_End event as you've
specified.

If the lifetime of the object is that of a user's session, Session_End should be used to dispose of the object. I'm not sure, but
I'd imagine that if the application is ending, all sessions will have time to cleanup via the Session_End event as well but this is
just an assumption
 
Another option is to write some code to recycle the application pool that
the application is running in. That gives you the desired effect you are
looking for without messing with the server life itself. You can find code
to recycle the app pool on MSDN

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 

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

Back
Top