asp.net-mvc 默认时间段后的 mvc 5 会话超时(20 分钟)

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/22365836/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-08 03:35:20  来源:igfitidea点击:

mvc 5 session timeout after default period (20 mins)

asp.net-mvcsession-variablesasp.net-mvc-5

提问by sarojanand

My MVC 5 site has web.config like this:

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

<authentication mode="Forms">
  <forms name=".ADAuthCookie" loginUrl="~/Account/Login" 
       timeout="2880" slidingExpiration="true" protection="All" />
</authentication>

but timeout doesn't work. It doesn't matter what value I give here, it always expires after 20-30 mins. How can I maintain users logged in for longer period or until they sign-out?

但超时不起作用。我在这里给出什么值并不重要,它总是在 20-30 分钟后过期。如何让用户保持登录更长时间或直到他们退出?

Is there any way I can achieve this using "In-Proc" only? Or I am missing something here?

有什么办法可以仅使用“In-Proc”来实现这一点?或者我在这里遗漏了什么?

回答by Kelly Gendron

You are dealing with two separate issues, auth timeout and session timeout. Session timeout is controlled by the following key in web.config...

您正在处理两个不同的问题,身份验证超时和会话超时。会话超时由 web.config 中的以下键控制...

  <system.web>
    <sessionState mode="InProc" timeout="30" />
  </system.web>

I'm not sure which you are encountering but I suspect it is the session timeout you are encountering rather than the authentication timeout... Try removing the timeout from your forms tag entirely and see if that gives you what you are looking for.

我不确定您遇到的是哪个,但我怀疑这是您遇到的会话超时而不是身份验证超时...尝试从您的表单标签中完全删除超时,看看是否能满足您的要求。

More information here- forms timeout issue in asp.net mvc

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