c# - ASP.NET Core 身份验证 cookie 不会过期
问题描述
在 IIS 中部署应用程序时,cookie 不会过期。使用 VS + IIS Express 进行测试时,一切正常。请参阅上面的设置。
在启动中:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationScheme = CookieAuthenticationDefaults.AuthenticationScheme,
AutomaticAuthenticate = true,
ExpireTimeSpan = TimeSpan.FromMinutes(3),
CookieSecure = env.IsDevelopment() ? CookieSecurePolicy.SameAsRequest :
CookieSecurePolicy.Always
});
在控制器中:
var principal = new ClaimsPrincipal(new ClaimsIdentity(GetUserClaims(claims, response.ContentObject.Jwt, username), CookieName));
await HttpContext.Authentication.SignInAsync(CookieName, principal);
解决方案
推荐阅读
- javascript - JS 应该在页面重新加载后保持它的工作
- css - 如何在桌子的每个 tr 上制作圆角
- tornadofx - 动态创建时是否有针对重复选项卡的修复?
- virtual-machine - 如何在 Xen 客户机中启用桥接网络?
- c - 用 C 实现 - 2018 年代码的出现:第 1_2 天
- c# - 我可以以编程方式访问 SSIS 对象的表达式属性吗?
- capl - 如何在 CAPL 中创建一个文件夹来保存图片?
- chromecast - 有没有办法在初始化时告诉 chromecast 接收器应用程序要使用哪个启动图像?
- cucumber - 黄瓜中显示小黄瓜关键字两次的范围报告,即 Given ,When Then
- android - 如何获取字符串值json解析