gpt4 book ai didi

asp.net-mvc - MVC 5注销超时

转载 作者:行者123 更新时间:2023-12-03 21:36:50 26 4
gpt4 key购买 nike

要求用户每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中。可以找到 key 生成器 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

最佳答案

即使您在本地运行站点,它也会发生吗?看看this blog post描述了类似的情况。

博客文章的重点是:

...remember that Forms Authentication uses the computer’s machineKey to encrypt the Forms Authentication cookie. "Could the machine key be changing over time on my shared hosting server?", I wondered.

Before emailing them to ask, I looked at the documentation on MSDN for machineKey and discovered that there is an AutoGenerate mode that can be set to regenerate a new machineKey each time the host process for a web application starts up…after 20 minutes of inactivity! Ah ha!

关于asp.net-mvc - MVC 5注销超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24479189/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com