[英]Run Application_Start immediately when application pool/Application restarts in IIS
What I want is that my Application_Start in Global.asax (Or any other piece of code) runs automatically whenever application pool/Application restarts in IIS. 我想要的是每当在IIS中重新启动应用程序池/应用程序时,Global.asax(或任何其他代码)中的Application_Start自动运行。 Application_Start gets triggered on the first request but I don't want to wait for the first request, but I want to do something whenever my Web API is deployed and started.
Application_Start在第一个请求上被触发,但是我不想等待第一个请求,但是我想在部署和启动Web API时做一些事情。
So, Is there any way via code (Not at IIS Level) that can achieve the above? 那么,是否可以通过代码(不在IIS级别)通过代码实现以上目的?
I'm not absolutely sure but you can try set "Start Mode = Always Running" for your application pool. 我不太确定,但是您可以尝试为应用程序池设置“开始模式=始终运行”。
Edit 1: This should enforce IIS to directly load/reload your application pool and thus triggering Application_Start of your Global.asax 编辑1:这应强制IIS直接加载/重新加载您的应用程序池,从而触发Global.asax的Application_Start
Edit 2 编辑2
Just to make it clear, this is what i meant. 为了清楚起见,这就是我的意思。
Yes this is not code based. 是的,这不是基于代码的。 But as of I know you have to configure application pool to achieve what you want.
但据我所知,您必须配置应用程序池才能实现所需的功能。
Maybe you want to check this too (contains samples for code based app pool configuration): Application Pool Defaults 也许您也想检查一下(包含基于代码的应用程序池配置的示例): 应用程序池默认值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.