ASP.NET Identity Session Timeout
16,092
public void ConfigureAuth(IAppBuilder app)
{
var sessionTimeout = 20; //
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
ExpireTimeSpan = TimeSpan.FromSeconds(30),
});
}
Author by
Yargicx
Updated on July 12, 2022Comments
-
Yargicx over 1 year
I use ASP.NET Identity .. I want to set session timeout to unlimited or max value. I've tried something but it doesn't effect. Note: I use shared hosting. Thank you.
//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())) ) } }); }