【发布时间】:2015-05-28 16:47:23
【问题描述】:
我有 Webform ASP.NET 4.5 应用程序。
在登录页面Session变量设置为:(相关代码简化)
Session["UserName"] = txtUserName.Text; (txtUserName.Text cannot be empty)
然后
Response.Redirect("Survey.aspx");
在调查页面我有
if (Session == null || Session["UserName"] == null)
{
string errorText = "Session was timed out due to inactivity, to continue, please close All of your Browser windows and log in again";
在 web.config 文件中我有:
<system.web>
<sessionState mode="InProc" timeout="1200" />
<compilation debug="true" targetFramework="4.5" />
<httpRuntime targetFramework="4.5" />
<customErrors mode="Off"> </customErrors>
</system.web>
我也有 IIS 本身
超时:02:00:00
仍有用户在 15-20 分钟后间歇性地报告会话超时。
这是什么原因造成的?
==============================
更新:将其设置为状态服务器后,我得到:
Unable to make the session state request to the session state server. Please ensure that the ASP.NET State service is started and that the client and server ports are the same. If the server is on a remote machine, please ensure that it accepts remote requests by checking the value of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\aspnet_state\Parameters\AllowRemoteConnection. If the server is on the local machine, and if the before mentioned registry value does not exist or is set to 0, then the state server connection string must use either 'localhost' or '127.0.0.1' as the server name.
【问题讨论】:
-
看你的应用程序池回收行为的配置。它可能被配置为定期回收,这将导致 InProc 会话丢失。
-
我还看到池从其他进程中回收,例如防病毒扫描文件。
-
如果您将会话设置为 StateServer 而不是 InProc,则会话信息应在池回收后继续存在。
-
@Joe,非常好的观点。设置为空闲超时分钟 (20) 这可能是造成这种情况的原因吗?