1
A
回答
1
那么,根据您的意见,您的问题是关于更改/更新/添加某个人的角色,但是您希望通过将他注销来反映此问题。 由于添加/更改,新角色不会反映到用户的cookie中,只会在数据库中反映出来。这就是他需要注销并重新登录才能进行此修改的原因。
事实上,如果你正在使用Cookie身份验证,怎么样在你的Startup.Auth.cs
尝试这样的:饼干上面
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.FromMinutes(1),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager))
}
});
在代码中使用OnValidateIdentity将验证用户的请求每validateInterval
分钟,所以才会更新一次1分钟。如果您提供TimeSpan.FromMinutes(0)
,则意味着每个用户的请求都会更新cookie。
请检查StackOverflow上的以下帖子和答案以解决此特定问题。
- MVC 5 AddToRole requires logout before it works?
- ASP.NET Identity, add another user to role instantly (they don't have to log out and in again)
- What is ASP.NET Identity's IUserSecurityStampStore<TUser> interface?
希望这会有所帮助。
相关问题
- 1. 当用户注销ASP.net MVC
- 2. ASP.NET MVC应用程序随机注销用户
- 3. MVC 5用OWIN自动注销用户
- 4. ASP.net MVC 3用户注册
- 5. asp.net c#MVC 5-注销活动目录用户
- 6. ASP.NET MVC在用户注销时显示消息
- 7. 未定义指数:注销
- 8. 通过sql注销asp.net用户?
- 9. ASP.NET/IIS:注销所有用户
- 10. ASP.Net LoginStatus注销重定向
- 11. 从MVC注销
- 12. ASP.NET MVC和ASP.NET成员:用户注册
- 13. 注销 - Taleo用户
- 14. Sharepoint用户注销
- 15. 注销所有活动用户在特定时间在asp.net
- 16. @login_required()不重定向注销用户
- 17. Laravel 5注销特定用户
- 18. 为什么我的asp.net身份的用户会自动注销
- 19. ASP.Net Identity从SQL注销
- 20. ASP.NET MVC注册用户数据库
- 21. 用于注销用户
- 22. IdentityServer4 - 注销后重定向到MVC客户端
- 23. ASP.NET MVC成员资格 - 用户经常注销 - 不知道为什么
- 24. 指定一个注销情况
- 25. 如何从我的asp.net应用程序注销用户?
- 26. IdentityServer3注销功能不适用于ASP.NET Core客户端
- 27. 强制注销所有在线用户中的特定用户
- 28. django sanction oauth2.0注销用户
- 29. 注销活动用户
- 30. 注销另一个用户
“指定的用户”,你的意思是当前登录的用户以外的用户? –
@ oj-raqueño是例如我是网站的管理员,我想注销网站的指定用户(成员)。 –
那么,如果你使用表单认证,你不能只是强迫他。他需要他的cookie到期。你可以做的是有一个短的cookie生活时间和锁定该用户(如果你使用ASP.NET身份)。 令牌的另一种方式是撤销令牌访问。你的认证过程是什么? – gdyrrahitis