用户被要求每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中的web.config置于system.web下。密钥生成器可以找到http://aspnetresources.com/tools/machineKey
我还迁移到了Identity 2.0,并保留了这些设置。使用这个博客作为guid迁移:http://typecastexception.com/post/2014/07/13/ASPNET-Identity-20-Extending-Identity-Models-and-Using-Integer-Keys-Instead-of-Strings.aspx
发布于 2014-08-27 10:47:36
即使您在本地运行站点,也会发生这种情况吗?看看描述类似案例的这篇博客文章。
这篇博客文章的要点是:
窗体身份验证的...remember使用计算机的machineKey加密窗体身份验证cookie。“在我的共享主机服务器上,机器密钥会随着时间的推移而改变吗?”我想。 在给他们发电子邮件询问之前,我查看了MSDN上的machineKey文档,发现有一种AutoGenerate模式可以在web应用程序的主机进程每次启动…时重新生成一个新的machineKey。在20分钟后,不活动的!啊哈!
发布于 2014-06-30 07:52:13
确保您没有任何后台ajax活动,因为它会影响会话(默认情况下,SlidingExpiration为真)。另外,在将ExpireTimeStamp从默认的14天更改为更小的值后,您必须手动删除旧的cookie。
https://stackoverflow.com/questions/24479189
复制相似问题