我有一个使用Microsoft.AspNetCore.Authentication(2.2.0)配置为使用CookieAuthentication的.net核心项目。 Cookies被配置为永久性,并在7天后过期。问题是,每当回收应用程序池时,所有登录的用户都会注销。
我根本不使用会话。我已经验证了该cookie仍然存在于Web浏览器中,好像现有的cookie被服务器确定为无效。如何更改此行为?
这是当前配置:
services
.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme)
.AddCookie(
CookieAuthenticationDefaults.AuthenticationScheme,
options =>
{
options.AccessDeniedPath = "/";
options.LoginPath = "/";
options.LogoutPath = "/Authentication/Logout";
options.Events.OnRedirectToLogin = context =>
{
context.Response.Redirect("/?returnUrl=" + context.Request.GetEncodedPathAndQuery());
return Task.CompletedTask;
});
答案 0 :(得分:1)
该错误是IIS中应用程序池的配置错误。在应用程序池的“高级设置”中,需要将“加载用户配置文件”设置设置为“ true”。