Ich habe eine neue ASP.NET MVC-Website mit ASP.NET Identity erstellt. Ich verwende die von Visual Studio 2017 generierte Standardlogik und wähle Individuelle Benutzerkonten.Login Timeout erhöhen
Alles funktioniert gut, außer dass es mich innerhalb von 10 - 20 Minuten Inaktivität abmeldet und ich würde gerne länger eingeloggt bleiben.
Nach dem googlen um, fand ich Informationen über die Einstellung CookieAuthenticationOptions.ExpireTimeSpan
. Mit dem Debugger kann ich jedoch sehen, dass dieser Wert standardmäßig auf 14 Tage eingestellt ist.
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>
Also, Wer weiß, wie die Höhe der Zeit zu erhöhen, bevor ich wegen protokolliert werden aus zur Inaktivität?
Danke, aber Forms Authentication ist der alte Weg und ASP.NET Identity ist der neue Weg. Sicherlich kann die einzige Antwort nicht sein, dass ich Dinge auf die alte Art tun muss. –