gpt4 book ai didi

ASP.NET 标识 session 超时

转载 作者:行者123 更新时间:2023-12-01 12:38:41 28 4
gpt4 key购买 nike

我使用 ASP.NET Identity .. 我想将 session 超时设置为无限制或最大值。我试过一些东西,但没有效果。注意:我使用共享主机。
谢谢你。

//web.config
<system.web>
<customErrors mode="Off" />
<httpRuntime targetFramework="4.5" />
<authentication mode="Forms" />
<sessionState timeout="500000" />
</system.web>

//asp.identiyt config
public void ConfigureAuth(IAppBuilder app)
{
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
ExpireTimeSpan = TimeSpan.FromDays(365),
LoginPath = new PathString("/user/login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser, int>
(
validateInterval: TimeSpan.FromDays(365),
regenerateIdentityCallback: (manager, user) => user.GenerateUserIdentityAsync(manager),
getUserIdCallback: (id) => (Int32.Parse(id.GetUserId()))
)
}
});
}

最佳答案

public void ConfigureAuth(IAppBuilder app)
{
var sessionTimeout = 20; //

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromSeconds(30),
});
}

关于ASP.NET 标识 session 超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27027748/

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