且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

ASP.NET 2.0会话超时

更新时间:2023-02-11 18:58:42

IIS花费precedence,但他们处理略有不同的方案。

IIS takes precedence, but they deal with slightly different scenarios.

在IIS的情况下,缺省为20分钟的时间里,出于对应用程序池是指传入的请求。如果你的应用程序不会接收所有20分钟的任何请求,那么应用程序池处于休眠状态以节省资源。当这种情况发生在你的应用程序的所有会话都没有了。

In the case of IIS, the default 20 minutes time-out for the application pool is referring to incoming requests. If your application doesn't receive any requests at all for 20 minutes then the application pool is put to sleep to save resources. When this happens all the sessions in your application are gone.

与每个会话的请求的ASP.NET会话超时交易。您的网站可能是相当忙碌的,但如果一个用户(即会话)不是20分钟仅该会话被丢弃活跃。

The ASP.NET session time-out deals with per-session requests. Your site could be quite busy, but if one user (i.e. session) is not active for 20 minutes only that session is discarded.

所以,是的,以确保会话保持存活60分钟,你必须更改IIS应用程序池超时设置以及web.config文件。

So yes, to make sure the session stays alive for 60 minutes you have to change the time-out settings for the IIS application pool as well as web.config.

处理这个问题的另一种方法是周期性地发送一个小的AJAX平(即具有随机ID到prevent浏览器缓存寻呼请求)回服务器。这样,只要用户不关闭浏览器,该会议将是preserved。

Another way of approaching this problem is to periodically send a small AJAX "ping" (i.e. a page request with a random ID to prevent browser caching) back to the server. This way, as long as the user doesn't close the browser, the session will be preserved.