ASP.NET MVC身份验证和会话超时

时间:2017-04-27 07:05:47

标签: asp.net-mvc

有人可以建议在我的asp.net mvc应用程序中进行表单身份验证的最佳方法。我的要求是,如果用户闲置5分钟,应用程序应自动重定向到登录页面。什么是最好的方法?

1 个答案:

答案 0 :(得分:0)

按如下方式更新您的web.config:

<system.web>

    <authentication mode="Forms">
      <forms name="AppName.Auth" loginUrl="~/Account/Login" protection="All" timeout="300" path="/"  slidingExpiration="true" />
    </authentication>

</system.web>

超时=&#34; 300&#34; - &GT; 5分x 60秒

所有使用[Authorize]属性修饰的MVC操作会在用户暂停5分钟后将用户重定向到登录页面。

相关问题