当我登录并将过期时间设置为 12 小时时,我会在 20 或 30 分钟后注销并重定向到登录页面。我不知道这是为什么。 这是我的代码
List<Claim> claims = new List<Claim>{
new Claim(ClaimTypes.Email, user.Email),
new Claim(ClaimTypes.Name, FullName),
new Claim(ClaimTypes.Surname, user.Username),
new Claim(ClaimTypes.UserData, "Active"),
new Claim(ClaimTypes.Sid, user.UserId.ToString()),
};
AuthenticationProperties authProperties = new AuthenticationProperties
{
IsPersistent = true,
ExpiresUtc = DateTime.UtcNow.AddHours(12),
AllowRefresh =true,
};
ClaimsIdentity identity = new ClaimsIdentity(claims, CookieAuthenticationDefaults.AuthenticationScheme);
ClaimsPrincipal cp = new ClaimsPrincipal(identity);
awaitHttpContext.SignInAsync(CookieAuthenticationDefaults.AuthenticationScheme,cp,authProperties);
我想在 12 小时后注销,但我在 20 分钟后注销了