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

查看:21
本文介绍了如何在 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
  • 在 Windows 安装中安装 Application Initialization 功能
  • 节点添加到web.config的节点
  • 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.

导航到应用程序中的任何网址(即使是不存在的网址)将启动应用程序并添加日志行.

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. 按照说明将 Application Initialization 功能安装到 Windows 安装中此处.
  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.

需要注意的一件重要事情是,如果应用程序初始化任务之前没有安装在机器上,您必须重新启动机器.这是我最后一次错过的东西,导致我浪费了很多时间寻找其他东西:(

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 :(

无论如何,设置这三件事会导致应用程序真正经历它的初始化,如果您想设置一些调度任务(ea 使用 Quartz NuGet 包).

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天全站免登陆