如何正确自动启动IIS10中的asp.net应用程序 [英] How to properly autostart an asp.net application in IIS10

查看:120
本文介绍了如何正确自动启动IIS10中的asp.net应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图让我的ASP.NET应用程序在应用程序池运行时自动启动.

I'm trying to get my ASP.NET application to automatically start whenever the application pool is running.

根据在线上的大量参考文献,我已经完成了以下工作:

As per the lots and lots of references online I have already done the following:

  • 将应用程序池设置为StartMode=AlwaysRunning
  • 将相关站点(属于上述池)设置为preloadEnabled=true
  • Application Initialization功能安装到Windows安装中
  • <applicationInitialization>节点添加到web.config的<system.webServer>节点
  • Set the Application Pool to StartMode=AlwaysRunning
  • Set the site in question (that belongs to beforementioned Pool) to preloadEnabled=true
  • Install the Application Initialization feature to the Windows installation
  • Add the <applicationInitialization> node to the web.config's <system.webServer> node

该Web应用程序基于Owin,并且在Startup.Configuration()方法中具有一个简单的log4net日志记录语句.现在,当重新启动IIS时,我看到w3svc.exe进程正在运行,因此我知道StartMode=AlwaysRunning正在工作.但是,日志文件中没有日志消息.

The web application is based on Owin and has a simple log4net logging statement in it's Startup.Configuration() method. Now when restarting IIS I see that the w3svc.exe process is running, so I know the StartMode=AlwaysRunning is working. There are however no logging messages in the log file.

导航到应用程序中的任何URL(甚至是不存在的URL)将启动应用程序并添加日志行.

Navigating to any url (even a nonexisting one) in the application will start the app and add the log line.

由于在启动应用程序时已经完成了实际工作,所以我真的希望应用程序真正地进行预加载,但是我似乎无法完成它.

Because of the actual work that's done in the startup of the application I really want the application to truly preload, but I seem to be unable to get it done.

很遗憾,搜索此站点我无法找到解决方案.

Searching this site I have unfortunately not been able to find a solution.

谢谢.

推荐答案

要为子孙后代回答我自己的问题,看来我走在正确的道路上.要使应用程序在IIS10中启动(我也假定在IIS 8中启动),您只需要执行以下三个步骤:

To answer my own question for future generations, it seems I was on the right track. To get the application to start in IIS10 (and I assume in IIS 8 as well) you only need the following three steps:

  1. 将应用程序池设置为StartMode=AlwaysRunning,以确保w3svc.exe进程始终在应用程序池中运行.
  2. 将相关站点(属于上述池)设置为preloadEnabled=true
  3. 按照
  1. Set the Application Pool to StartMode=AlwaysRunning to make sure the w3svc.exe process is always running for the App Pool.
  2. Set the site in question (that belongs to beforementioned Pool) to preloadEnabled=true
  3. Install the Application Initialization feature to the Windows installation as per the instructions here.

要注意的一件事是,如果以前没有在计算机上安装Application Initialization任务,则必须重新启动计算机.这是我上次错过的时间,这导致浪费大量时间寻找其他东西:(

One important thing to note is that if the Application Initialization task was not previously installed on the machine you must reboot the machine. This is what I missed the last time which led to quite some time wasted looking for other things :(

无论如何,设置这三件事将导致应用程序实际进行初始化,如果您要设置一些计划任务(例如,使用

Anyway, setting up those three things will cause the app to actually go through it's initialization, which is especially useful if you want to setup some scheduling task (ea using the Quartz NuGet package).

请注意,如果您像上面那样设置自动初始化,则应用程序还将在关闭超时到期且应用程序池回收后自动启动.

Note by the way that if you setup auto initialization like above, the application will also automatically start after the shutdown timeout has expired and on application pool recycles.

这篇关于如何正确自动启动IIS10中的asp.net应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆