简体   繁体   English

在IIS上发布网站或IIS启动后如何执行页面或代码

[英]How to execute Page or Code after website is published on IIS or IIS starts

I have an ASP .NET WebSite project (Web Forms) hosted on IIS 7 but I need to execute the application_start (Global.asax) because I load some stuffs there., so I'm looking for a way to execute this code right after I publish the code and/or when IIS restart, 我在IIS 7上托管了一个ASP .NET WebSite项目(Web窗体),但是我需要执行application_start(Global.asax),因为我在那里加载了一些东西。因此,我正在寻找一种方法来立即执行此代码我发布代码和/或IIS重新启动时,

I don't need to debug, I just need to run a process in the application_start to load the cache info in a background process., 我不需要调试,只需要在application_start中运行一个进程即可在后台进程中加载​​缓存信息。

So the first time I open the website be able to run it fast and all cache data will be available, and the application_start runs the first time the website is executed/opened so that's why I need to find an automatic way to execute the application_start right after the IIS is restarted or the website is published., right now I need to manually open the website 因此,我第一次打开网站就可以快速运行它,并且所有缓存数据都将可用,而application_start在第一次执行/打开网站时运行,因此这就是为什么我需要找到一种自动执行application_start的方式的原因IIS重新启动或网站发布后。,现在我需要手动打开网站

What you need is Application Initialization module in IIS.The original article is quite overwhelming ,a 您需要的是IIS中的“ 应用程序初始化”模块 。原始文章相当繁琐,

  • install the Application Initialization Module 安装应用程序初始化模块
  • After the feature has been installed and you have configured an ASP.NET web site, set the startMode of the application pool to AlwaysRunning. 安装该功能并配置ASP.NET网站后,将应用程序池的startMode设置为AlwaysRunning。

( 在IIS中设置startMode

Setting the startMode will start the Application and thus >will trigger your Application_Start in global.asax. 设置startMode将启动应用程序,从而>将在global.asax中触发您的Application_Start。

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

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