简体   繁体   English

防止 IIS 卸载 ASP.Net 站点

[英]Prevent IIS from unloading ASP.Net site

How do I prevent an ASP.Net site from being unloaded by IIS?如何防止 ASP.Net 站点被 IIS 卸载?

I have what may be the dumbest website in the world - once per hour it wakes up and writes a timestamp to a log file.我有一个可能是世界上最愚蠢的网站——它每小时唤醒一次并将时间戳写入日志文件。 When the app starts, it says so with a timestamp in the log, and when it dies, same thing.当应用程序启动时,它会在日志中显示一个时间戳,当它死亡时,同样的事情。

In IIS I went into its Application Pool and set the Idle Timeout to 0 and set Generate Recycle Event Log Entry > Regular Time Interval to False.在 IIS 中,我进入其应用程序池并将空闲超时设置为 0,并将生成回收事件日志条目 > 定期时间间隔设置为 False。

Yet the site still unloads itself about once per day - I get the App Unloading... entry in the log and it sits dead until I next visit it.然而,该站点仍然每天大约卸载一次 - 我在日志中收到 App Unloading... 条目,它一直处于死状态,直到我下次访问它。

How do I prevent it from unloading?如何防止它卸载?

(Obviously this site will do more once I get this resolved - for now it's as simple as possible to isolate the problem.) (显然,一旦我解决了这个问题,这个网站会做更多的事情 - 现在它尽可能简单地隔离问题。)

The application pool has another property that causes it to be automatically recycled every N minutes (defaults to 1740, or every 29 hours.) Make this zero to disable recycling.应用程序池有另一个属性,它会导致它每 N 分钟自动回收一次(默认为 1740 或每 29 小时)。将此设置为零以禁用回收。 The property is (on IIS7) under the "Recycling" heading and is called "Regular Time Interval (minutes)"该属性(在 IIS7 上)位于“回收”标题下,称为“常规时间间隔(分钟)”

In addition to @jlew's recommendation, the guidance in this article is important if you're running a background task/timer continuously/periodically in ASP.Net without the install/configuration/maintenance burden of Windows Services and Scheduled Tasks:除了@jlew 的建议之外,如果您在 ASP.Net 中连续/定期运行后台任务/计时器,而没有 Windows 服务和计划任务的安装/配置/维护负担,那么本文中的指导也很重要:

http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx http://haacked.com/archive/2011/10/16/the-dangers-of-implementing-recurring-background-tasks-in-asp-net.aspx

It includes a useful helper library, WebBackgrounder, which abstracts the advice in the article to handle graceful shutdown and some of the typical wants/needs of a background task.它包括一个有用的帮助程序库 WebBackgrounder,它抽象了文章中的建议,以处理正常关闭和后台任务的一些典型需求。

It does not configure IIS for you - you'll need to modify the recycling settings yourself.它不会为您配置 IIS - 您需要自己修改回收设置。

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

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