【发布时间】:2014-08-20 04:17:52
【问题描述】:
要求用户每 20 分钟左右登录一次。
不知道在哪里寻找的情况之一。我正在使用 C# MVC 5 IdentityFramework 1.0.0
我想将超时时间设置为 4 小时。
到目前为止,我已经在 web.config 中尝试过:
<system.web>
<sessionState timeout="2880"></sessionState>
<authentication mode="Forms">
<forms loginUrl="~/Account/Login" timeout="2880" />
</authentication>
</system.web>
在 Startup.Auth.sc 中:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromHours(4),
CookieSecure = CookieSecureOption.Never,
CookieHttpOnly = false,
SlidingExpiration = true,
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login")
});
我错过了什么?
编辑 - 解决方案
解决方法是将machineKey放在system.web下的web.config中。密钥生成器可以找到http://aspnetresources.com/tools/machineKey
我还迁移到了 Identity 2.0 并保留了这些设置。使用此博客作为指导进行迁移:http://typecastexception.com/post/2014/07/13/ASPNET-Identity-20-Extending-Identity-Models-and-Using-Integer-Keys-Instead-of-Strings.aspx
【问题讨论】:
-
您实际面临的问题是什么?
-
要求用户每 20 分钟左右登录一次。
-
您的问题解决了吗?我对解决方案感兴趣
-
问题已更新为解决方案。感谢提示解决方案
-
按说的工作:)
标签: asp.net-mvc entity-framework authentication logout