【问题标题】:session time out happening before the time mentioned in webconfig会话超时发生在 Web 配置中提到的时间之前
【发布时间】:2016-03-22 07:03:28
【问题描述】:

在 webconfig 中我提到会话超时为 20 分钟

    <system.web>

        <compilation debug="true" targetFramework="4.5" />
        <httpRuntime targetFramework="4.5" maxRequestLength="350000" enableVersionHeader="false" 
maxQueryStringLength="3584" executionTimeout="600"/>
        <sessionState mode="InProc" timeout="20"></sessionState>
            <globalization culture="en-GB" />
      </system.web>

但网站在 20 分钟空闲时间之前退出。 我在代码中遗漏了什么?

【问题讨论】:

    标签: asp.net-mvc asp.net-mvc-3 session


    【解决方案1】:

    由于会话信息存储在内存中(mode="InProc"),如果重新启动应用程序域,所有会话信息将被删除。如果您在开发时在本地观察到这一点,则每次重新编译应用程序时,都会发生这种情况。如果您在 Web 服务器上观察到这种行为,那么 IIS 也可能会回收应用程序域。因此,您可能需要考虑其他一些session state modes,例如StateServerSQLServer

    到目前为止,我已经谈到了 ASP.NET Session。但也有身份验证。由于您谈到用户正在注销,因此如果您使用表单身份验证,cookie 可能会过期。这由配置中的 &lt;authentication&gt; 标签控制:

    <authentication mode="Forms">
        <forms loginUrl="~/Account/Login" timeout="2880" protection="All" />
    </authentication>
    

    所以你也可以检查这个超时。

    底线:不要将 ASP.NET 会话与 ASP.NET 表单身份验证混淆。

    【讨论】:

    • 无法启用 StateServer..also 出现内部错误
    • 您是否启动了将充当状态服务器的 Windows 服务?还有你得到什么样的错误?
    • stateserver 已启用,但是当我给 标签时,它给了我 500-bad 错误...
    • 感谢您的回答,这是因为 Inproc..当我更改为 StateServer 时它很好..但仍然与 标签混淆
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-08-14
    • 1970-01-01
    • 2016-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多