【发布时间】:2014-11-19 21:52:53
【问题描述】:
我使用 ASP.NET Identity .. 我想将会话超时设置为无限制或最大值。我尝试了一些东西,但它没有效果。注意:我使用共享主机。 谢谢。
//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()))
)
}
});
}
【问题讨论】:
-
请注意,Session 和身份登录不一定是一回事。还;试图“永远”保持会话是一个非常非常糟糕的主意。而且几乎不可能。
-
好的。例如,我想要一周的超时时间?
标签: asp.net session asp.net-identity