简体   繁体   English

在IIS中重新启动应用程序池时立即运行Application_Start

[英]Run Application_Start immediately when application pool restarts in IIS

We are doing some caching operations in the application_start phase in the application. 我们正在应用程序的application_start阶段进行一些缓存操作。 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 ? 是否可以在应用程序池重新启动时触发application_start,或者您是否有更好的想法来解决此问题?

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 . 您可以使用IIS 7.5的应用程序初始化 ,它借用IIS8的功能,或者如果您使用的是ASP.NET 4.0 +,则应用程序自动启动

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 对于ASP.NET 2.0 i 3.5,有一个IMO有些hackish解决方案,您可以在事件日志中记录应用程序池回收,然后在事件日志中设置将在该事件上执行的任务,这里是详细信息

Application_Start is called only at the first request. 仅在第一个请求时调用Application_Start。 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. 您的CacheManager可以决定是否需要自动加载数据。

Are you afraid the first request will be slower ?. 你害怕第一个请求会慢吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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