【问题标题】:increase session time out in asp.net mvc web aplication在 asp.net mvc Web 应用程序中增加会话超时
【发布时间】:2018-12-07 09:25:32
【问题描述】:

在我的 Web 应用程序中,我在 system.web 标记内的 web.config 文件中将会话超时设置为 60 分钟,但是它不起作用。 30 分钟后,其会话过期。请查看我下面的代码并帮助我。

<system.web>
  <customErrors mode="Off">
</customErrors>
    <authentication mode="None" />
    <compilation targetFramework="4.5.2" />
    <httpRuntime targetFramework="4.5" />
     <caching>
      <outputCacheSettings>
        <outputCacheProfiles>
          <add name="CacheOneDay" duration="86400" varyByParam="IFAID" />
        </outputCacheProfiles>
      </outputCacheSettings>
    </caching>
<sessionState timeout = "60" mode = "InProc" />
  </system.web>

【问题讨论】:

  • 检查您的 global.asax 文件。如果那里设置了超时,它将覆盖 web.config 设置

标签: c# asp.net model-view-controller session-timeout


【解决方案1】:

可以通过 3 种方式设置会话超时:

  • 您可以使用 web.config 中 sessionState 元素的 timeout 属性以分钟为单位增加超时值。

  • 你可以在代码中设置

    会话["UserId"] = 1234;
    会话超时 = 60;

  • 如果您使用表单身份验证,请同时检查身份验证超时值。

您已经检查并应用了第一项。您可以在您的解决方案中搜索Session.Timeout,或者如果您正在使用表单身份验证检查它的超时变量。

【讨论】:

  • 我应该在我的 web-config 或 Code behind 中哪里写“Session.Timeout = 60”?
猜你喜欢
  • 2011-09-23
  • 2015-01-02
  • 2019-06-23
  • 1970-01-01
  • 1970-01-01
  • 2015-09-25
  • 2017-09-17
  • 1970-01-01
  • 2014-03-26
相关资源
最近更新 更多