简体   繁体   中英

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

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?

How about:

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM