问题描述
通过的托管网站IIS 7.0
的我想我的会话超时设置为我的ASP.NET应用程序9小时。结果
这已被设定在的web.config
<的sessionState超时=540>< /&的sessionState GT;
不过,按照我的理解,如果超时设置为IIS 20分钟内,其中的网站托管,设定一个扩展的会话状态将是没有用的。
首先,我想证实这个假设是否正确。
问题是,我没有访问我的共享托管的Web服务器的IIS。
现在,一些研究后,我想出了在code项目的另一种解决方案。这听起来像一个 。我们的想法是插入一个iframe来母版页。在iframe包含另一个网页的元刷新不到20分钟。
Response.AddHeader(刷新,20);
这个想法似乎对我好。但文章是7岁。加上评论部分用户的抱怨,如果页面最小化,我很担心,同样的情况发生时,我的网页标签不活跃,这将无法工作。
我想知道这些事情。
- 是否刷新方法将我的情况下工作,即使页面最小化?
- 是否有任何其他的方法,可以增加覆盖IIS超时设置? 会话超时
- 此外,我读堆栈溢出的一些问题,其中的的答案状态IIS会话超时是CLASIC ASP页的。那么,为什么不是我延长超时不费一枪?
Yes, this assumption is absolutely right in case you are using in-memory session state mode. In this case the session is stored in memory and since IIS could tear down the AppDomain under different circumstances (period of inactivity, CPU/memory tresholds are reached, ...) the session data will be lost. You could use an out-of-process session state mode. Either StateServer or SQLServer. In the first case the session is stored in the memory of a special dedicated machine running the aspstate Windows service and in the second case it is a dedicated SQL Server. The SQL Server is the most robust but obviously the slowest.
The hidden iframe still works to maintain the session alive but as I said previously there might be some conditions when IIS unloads the application anyway (CPU/memory tresholds are reached => you could configure this in IIS as well).
The previous method doesn't increase the session timeout. It simply maintains the session alive by sending HTTP requests to the server at regular intervals to prevent IIS from bringing the AppDomain down.
There is no such thing as IIS session timeout. The session is an ASP.NET artifact. IIS is a web server that doesn't know anything about sessions.
Personally I don't use sessions in my applications. I simply disable them:
<sessionState mode="Off"></sessionState>
and use standard HTTP artifacts such as cookies, query string parameters, ... to maintain state. I prefer to persist information in my backend and retrieving it later using unique ids instead of relying on sessions.
这篇关于增加会话超时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!