您好, 欢迎来到 !    登录 | 注册 | | 设为首页 | 收藏本站

如何使用ASP.NET Identity 2.0.1将角色更改强制传播给用户?

如何使用ASP.NET Identity 2.0.1将角色更改强制传播给用户?

如果要启用Cookie的即时吊销,则每个请求都必须命中数据库以验证Cookie。因此,延迟之间的权衡在于数据库负载。但是您始终可以将validationInterval设置为0。

app.UseCookieAuthentication(new CookieAuthenticationOptions
{
    AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
    LoginPath = new PathString("/Account/Login"),
    Provider = new CookieAuthenticationProvider
    {
        // Enables the application to validate the security stamp when the user logs in.
        // This is a security feature which is used when you change a password or add an external login to your account.  
        OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
            validateInterval: TimeSpan.FromSeconds(0),
            regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
    }
});
dotnet 2022/1/1 18:13:37 有628人围观

撰写回答


你尚未登录,登录后可以

和开发者交流问题的细节

关注并接收问题和回答的更新提醒

参与内容的编辑和改进,让解决方法与时俱进

请先登录

推荐问题


联系我
置顶