c# - 如何在 ASP.NET Core Identity 中注销用户

标签 c# asp.net-core asp.net-core-mvc asp.net-core-identity

我正在尝试注销我正在更改的用户的所有事件 session (删除、添加或删除角色、更改密码等)。

我找到了适用于旧版本 ASP .NET 的解决方案。本质上调用 UserManager.UpdateSecurityStampAsync(userId); 但这似乎不适用于 ASP .NET Core。我可以调用该函数,但它什么也不做。之后用户仍处于登录状态。

那么我究竟该如何注销已登录的用户(所有打开的 session )?

最佳答案

IdentityOptions 有一个名为 SecurityStampValidationInterval 的属性,它设置验证 cookie 的频率。默认设置为 30 分钟。你可以改变它:

services.Configure<IdentityOptions>(options =>
{
     options.SecurityStampValidationInterval = TimeSpan.FromSeconds(0);             
});

关于c# - 如何在 ASP.NET Core Identity 中注销用户,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40716750/

相关文章:

c# - 如何指定一个子元素在全局命名空间中?

c# - 不同派生类型的 WinForms 设计器属性

c# - ASP.NET Core 服务不会重定向 http :localhost:<https-port> to https schema

asp.net-core - 如何从 Blazor 中的数据库获取经过身份验证的用户

asp.net-core - MailKit.Security.SslHandshakeException : The host name did not match the name given in the server's SSL certificate. asp.net 核心 5,nginx

c# - 如何从通过 API 返回的 Task<IActionResult> 获取值进行单元测试

c# - NET CORE MVC - 如何使用嵌套的多参数化路由

asp.net - 如何在像DDD这样的ASP.NET CORE解决方案中组织多个项目?

c# - 无法构建其中包含 processTemplate.xaml 的项目

c# - 尝试使用标记扩展时出错