我正在使用的ASP.NET零版本7的ASP.NET核心,MVC和jQuery项目。
我正在尝试设置会话超时/到期时间,以便在应用程序空闲一段时间时自动从应用程序中注销。有人能告诉我怎么做吗?
在ASP.NET零版本8中,它们在用户管理设置中提供此配置。
发布于 2019-12-18 13:12:02
ASP.NET核心MVC
MVC的会话到期是通过cookie提供的,它独立于ASP.NET核心,独立于ASP.NET零。
调用ConfigureApplicationCookie后IdentityRegistrar.Register in Startup.cs
public IServiceProvider ConfigureServices(IServiceCollection services)
{
// ...
IdentityRegistrar.Register(services); // No change
AuthConfigurer.Configure(services, _appConfiguration); // No change
services.ConfigureApplicationCookie(o =>
{
o.ExpireTimeSpan = TimeSpan.FromHours(1);
o.SlidingExpiration = true;
});
// ...
}来自ASP.NET Core v2.2.8 CookieAuthenticationOptions.cs#L30-L36的缺省值
public CookieAuthenticationOptions()
{
ExpireTimeSpan = TimeSpan.FromDays(14);
ReturnUrlParameter = CookieAuthenticationDefaults.ReturnUrlParameter;
SlidingExpiration = true;
Events = new CookieAuthenticationEvents();
}ASP.NET零(用于ASP.NET核心)
ASP.NET Zero v7.2.0+提供:
https://stackoverflow.com/questions/59389438
复制相似问题