你能阻止你的 ASP.NET 应用程序关闭吗? [英] Can you prevent your ASP.NET application from shutting down?

查看:31
本文介绍了你能阻止你的 ASP.NET 应用程序关闭吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想我听说 ASP.NET 应用程序会在闲置一段时间后关闭(即没有访问者).

I think I heard that ASP.NET applications will shut down after a while of being idle (i.e. no visitors).

有没有办法防止这种行为发生?我有一个计时器,它运行 global.asax.cs application_start 事件中的一些代码,并希望确保它继续运行,即使没有访问者访问该网站.

Is there a way to prevent this behavior from happening? I have a timer that runs some code from the global.asax.cs application_start event, and want to make sure that it continues to run, even when no visitors are hitting the site.

提前致谢!

推荐答案

你可以通过几种方式做到这一点.

You can do it a few ways.

  1. 如果您可以控制 IIS,则可以更改应用程序池中的空闲超时",默认为 20 分钟.
  2. 如果您无法控制 IIS(共享或其他托管),您可以使用外部服务来 ping 站点.MyWebKeepAlivePingdom 是不错的选择.
  1. If you have control over IIS, you can change the "Idle Timeout" within the application pool, by default it is 20 minutes.
  2. If you do NOT have control over IIS (Shared or other hosting), you can use an external service to ping the site. MyWebKeepAlive or Pingdom are good options for this.

如果您在选项二下,我强烈建议您使用外部源,因为它不太易于管理,而且如果您没有可用于配置的 IIS,则您很可能没有可用于添加 ping 的服务器申请到.

If you are under option two, I strongly recommend an external source, as it is less to manage, and if you don't have IIS available to configure, you most likely don't have the server available to add a ping application to.

此外,我不建议使用 Web 应用程序的进程中的内容,因为我发现当应用程序确实需要回收时,这些内容可能会导致问题......

In addition, I do not recommend something that sits in-process with the web application, as I have found that those can cause issues when the application really does need to recycle...

最后一个想法

如果您确实走修改 IIS 空闲超时的路线,我建议您设置应用程序池的定期回收.由于许多 Web 应用程序确实受益于定期回收,最常见的是空闲超时是最大的常规回收因素.

If you do go the route of modifying the IIS Idle timeout, I do recommend setting a regular recycle of the application pool. As many web applications do benefit from a periodic recycle, and most commonly the idle timeout is the biggest regular recycle factor.

这篇关于你能阻止你的 ASP.NET 应用程序关闭吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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