简体   繁体   中英

Run Application_Start immediately when application pool restarts in IIS

We are doing some caching operations in the application_start phase in the application. So all the cache is going away when the application pool restarts. Is it possible to trigger application_start when the application pool restarts or do you have better ideas to solve this problem ?

You could use Application Initialization for IIS 7.5 , it borrows functionality from IIS8, or if you are using ASP.NET 4.0 + there is application auto start .

For ASP.NET 2.0 i 3.5 there is a IMO somewhat hackish solution, you can log application pool recycle in Event log and then in event log set a task that will be performed on that event, here are the details

Application_Start is called only at the first request. I'm not sure it's a good idea to cache something if no requests are made.

I would you simply load the cache upon the first request.
Your CacheManager could decide if it's need to load it's data automatically.

Are you afraid the first request will be slower ?.

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