默认期后mvc 5会话超时(20分钟)

sar*_*and 23 asp.net-mvc session-variables asp.net-mvc-5

我的MVC 5站点有这样的web.config:

<authentication mode="Forms">
  <forms name=".ADAuthCookie" loginUrl="~/Account/Login" 
       timeout="2880" slidingExpiration="true" protection="All" />
</authentication>
Run Code Online (Sandbox Code Playgroud)

但超时不起作用.我在这里给出的价值无关紧要,它总是在20-30分钟后到期.如何维护用户登录更长时间或直到他们退出?

有没有办法只使用"In-Proc"来实现这个目的?或者我在这里遗失了什么?

Kel*_*ron 37

您正在处理两个单独的问题,即auth超时和会话超时.会话超时由web.config中的以下键控制...

  <system.web>
    <sessionState mode="InProc" timeout="30" />
  </system.web>
Run Code Online (Sandbox Code Playgroud)

我不确定你遇到了什么,但我怀疑它是你遇到的会话超时而不是身份验证超时...尝试完全从你的表单标签中删除超时,看看它是否能满足你的需求.

更多信息在这里 - 形成asp.net mvc中的超时问题

  • 我试过这个,但是经过身份验证的登录仍然有效,即使等待超过`timeout`持续时间. (2认同)