【问题标题】:session timeout not working in mvc会话超时在 mvc 中不起作用
【发布时间】:2014-11-17 15:49:18
【问题描述】:

我已在我的 web.config 中完成此操作。

<system.web>
  <sessionState mode="InProc" timeout="3"></sessionState>
  <authentication mode="Forms" >
    <forms loginUrl="~/Account/Login" timeout="2880"/>
  </authentication>

会话超时后,它会清除所有数据,但不会重定向到登录页面。

【问题讨论】:

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


    【解决方案1】:

    会话超时与身份验证超时无关 - InProc 会话保存在内存中,而身份验证令牌是一个包含到期日期/时间的 cookie。

    您需要做的是在global.asax 中的Session_Ended 事件中强制验证票证到期 - 请参阅此answer,了解如何执行此操作,因为它不仅仅是调用FormsAuthentication.SignOut 那么简单.

    【讨论】:

    • protected void Session_End(object sender, EventArgs e) { FormsAuthentication.SignOut();会话.清除();会话.Abandon(); Response.RedirectToRoute("~/Account/LogOff"); }
    • session_end 命中但未重定向。也无法退出。
    猜你喜欢
    • 2016-07-11
    • 2014-12-13
    • 2016-03-15
    • 2014-12-05
    • 1970-01-01
    • 2016-01-21
    • 2015-04-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多