2017-04-23 106 views
1

我有我在IIS 7.5上托管的Asp.Net Web-Api应用程序。 我想在应用程序池启动(回收)时指定我的应用程序时执行一些任务。我知道从IIS 7.5开始有应用程序初始化模块。 但为此我需要设置应用程序池配置=>startMode =“AlwaysRunning”。 即使没有长时间的服务请求,这也会使应用程序池始终运行。 有什么办法在我的应用程序启动时,我可以执行初始化任务,而不保持应用程序池始终运行?引导Asp.Net应用程序不使用IIS应用程序池配置StartMode =“AlwaysRunning”

回答

0

您可以将Global.asax文件添加到您的项目并使用Application_Start方法。 Info from MS

protected void Application_Start(object sender, EventArgs e) 
{ 
    //this will run every time the app is started. 
} 

有更多的可用

  • Application_AuthenticateRequest
  • 的Application_BeginRequest
  • Application_End
  • 的Application_Error
  • Session_End中
  • 在session_start
+0

我不想在'Application_Start'中执行启动任务,因为它将在对应用程序的第一个请求中调用。我想在应用程序池启动时执行初始化任务。 –