c# - 关闭浏览器 ASP.NET MVC 后如何注销用户
问题描述
PasswordSignInAsync
我使用类似的功能登录
var result = await SignInManager.PasswordSignInAsync(model.UserName, model.Password, model.Remember, shouldLockout: false);
并且字段model.Remember (isPersistent)
是错误的。
在我的 Startup 课程中,我有一些代码,例如
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))
}
});
我想要实现的不仅是在 30 分钟后注销用户,还要在关闭浏览器后注销用户。
解决方案
你window.unload
从客户端尝试清除cookie吗?也许这可以解决您的问题。
推荐阅读
- servlets - 如何为每个路径指定 servlet 错误页面
- c++ - 如何从 C++/WinRT 代码动画移动图像?
- python - 调整 DHT22 python 脚本的温度输出
- php - WINdows10/Chrome 中的 Jquery 自动完成功能
- javascript - 我的 JavaScript 倒数计时器无法正常工作
- javascript - React 基于三个逻辑路径渲染各种组件
- flutter - 针对不同屏幕尺寸在特定像素位置绘制小部件
- excel - 在 Mac Office 上从 Excel 选择性粘贴到 Powerpoint
- azure - 将 Azure CDN 下载限制为 Azure Active Directory 客户端
- powershell - 我无法使用 move-item 功能将多个文件移动到单独的文件夹中