I created a new ASP.NET MVC website using ASP.NET Identity. I'm using the standard logic generated by Visual Studio 2017, and I selected Individual User Accounts.
Everything works fine except that it seems to log me out within about 10 - 20 minutes of inactivity, and I'd like to stay logged in for longer than that.
After Googling around, I found information about setting CookieAuthenticationOptions.ExpireTimeSpan. However, using the debugger, I can see that this value is set to 14 days by default.
Startup.Auth.cs:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromMinutes(30),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
},
//SlidingExpiration = true, // Default: true
//ExpireTimeSpan = TimeSpan.FromHours(1) // Default: 14 days
});
Web.Config:
<system.web>
<authentication mode="None" />
<compilation debug="true" targetFramework="4.6" />
<httpRuntime targetFramework="4.5.2" executionTimeout="240" maxRequestLength="20480" />
<httpModules>
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" />
</httpModules>
<customErrors mode="Off"></customErrors>
</system.web>
<system.webServer>
<modules>
<remove name="FormsAuthentication" />
<remove name="ApplicationInsightsWebTracking" />
<add name="ApplicationInsightsWebTracking" type="Microsoft.ApplicationInsights.Web.ApplicationInsightsHttpModule, Microsoft.AI.Web" preCondition="managedHandler" />
</modules>
<validation validateIntegratedModeConfiguration="false" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="20971520" />
</requestFiltering>
</security>
</system.webServer>
So, does anyone know how to increase the amount of time before I get logged out due to inactivity?