How do I add a Application_End handler without using global.asax?

668 Views Asked by At

I'm writing an http module, and I want to add a method that is called when (and only when) the appdomain gets recycled. I don't want to add anything to global.asax, I want to do it programatically within the http module.

However, there doesn't seem to be an End event on the instance of HttpApplication passed in the module's Init method. How can I subscribe to the Application_End event?

1

There are 1 best solutions below

0
On

How about:

AppDomain.CurrentDomain.DomainUnload +=new EventHandler(CurrentDomain_DomainUnload);

This I believe is more accurate than Application.End which should cover the recycles.