我使用ASP.NET身份创建了一个新的ASP.NET MVC网站。我使用由Visual Studio 2017生成的标准逻辑,并且我选择了个人用户帐户。增加登录超时
一切工作正常,只是它似乎在约10至20分钟的不活动状态下注销我,我想保持登录更长的时间。
Googling around后,我发现有关设置CookieAuthenticationOptions.ExpireTimeSpan
的信息。但是,使用调试器,我可以看到这个值默认设置为14天。
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>
所以,没有人知道如何增加的时间量我得到注销由于前不活动?
谢谢,但表单身份验证是旧的方式,ASP.NET身份是新的方式。当然,唯一的答案不能是我必须以旧的方式做事。 –