【问题标题】:Logout the user when that user deleted in ASP.NET Core在 ASP.NET Core 中删除该用户时注销该用户
【发布时间】:2021-09-30 13:04:09
【问题描述】:

我使用的是 ASP.NET Core 5.0,并且我有一个基于声明和角色的身份验证。当我删除它时,我想注销用户。我已经尝试添加到我的Startup.cs

services.Configure<SecurityStampValidatorOptions>(options =>
{
    // enables immediate logout, after updating the user's security stamp.
    options.ValidationInterval = TimeSpan.Zero;   
});

它不工作。

我没有使用UserManager进行认证和授权。

【问题讨论】:

    标签: .net asp.net-mvc asp.net-core authentication authorization


    【解决方案1】:

    我认为您不应该将Zero 作为一个值。 试试这个:-

    services.Configure<SecurityStampValidatorOptions>(options =>
    {
        options.ValidationInterval = TimeSpan.FromMinutes(1);
    });
    

    它会解决你的问题。

    【讨论】:

    • 但每个人都在使用Zero。我要再试一次
    • 我认为你没有很好地阅读我的答案。我是说我没有在身份验证中使用UserManager。所以它对我没用。
    • @BerkGarip 你必须先AddIdentity,然后再ConfigureApplicationCookie。是你吗?
    • 怎么做,在哪里做? @PritomSarkar
    猜你喜欢
    • 1970-01-01
    • 2013-05-02
    • 1970-01-01
    • 1970-01-01
    • 2015-06-30
    • 1970-01-01
    • 1970-01-01
    • 2021-03-07
    • 1970-01-01
    相关资源
    最近更新 更多