1

假设我有一个由 IIS 托管的 ASP.Net Web 应用程序。除了服务请求的功能之外,我还添加了一个按指定时间间隔定期执行的操作,例如每 30 分钟一次。此操作与外部 Web 请求无关,例如,其目的是删除无用的日志文件。

问题是:如果长时间(一天、一周)没有人访问我的网站,IIS 是否仍会使我的应用程序保持活动状态,并且上述操作将每 30 分钟执行一次。或者如果长时间没有请求,IIS 将关闭/暂停应用程序的活动?

也许这是一个蹩脚的问题,但我没有找到明确的答案。

4

1 回答 1

2

IIS doesn't shut down, but IIS will recycle your app after a certain period of time of unuse.

So if your app is responsible for firing off the event, then no it won't run if your app is not running (recycled).

Either have a service hit your website once in awhile or setup a scheduled task on the server if you have access to the machine.

If you're on shared hosting you'll have to check their features to see if they have something like that.

Also, if you're just trying to delete log files or something trivial and not time sensitive (since you won't have logs unless someone is hitting your site), you could just perform your action in Application_Start. This even will fire whenever IIS restarts your application.

于 2013-09-26T14:06:43.633 回答