Her*_*Giz 9 authentication asp.net-mvc entity-framework logout
要求用户每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>
Run Code Online (Sandbox Code Playgroud)
在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")
});
Run Code Online (Sandbox Code Playgroud)
我错过了什么?
编辑 - 解决方案
解决方案是将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
小智 0
确保您没有任何后台 ajax 活动,因为它会影响会话(SlidingExpiration 默认情况下为 true)。此外,在将 ExpireTimeStamp 从默认的 14 天更改为更小的值后,您还必须手动删除旧的 cookie。
| 归档时间: |
|
| 查看次数: |
3510 次 |
| 最近记录: |