我有两个与此相关的问题:
1)我需要使用Asp.Net Identity 2将一些远程用户添加/删除后,使invalid.AspNet.ApplicationCookie无效.我尝试使用UpdateSecurityStamp,但由于没有更改密码或用户名,因此SecurityStamp保持不变.当我使用ApplicationRoleManger时,我可以看到用户角色已更新,但在User.Identity声明中,它们保持不变.
2).AspNet.ApplicationCookie验证如何工作以及如何访问它?
我试图使用此代码,但没有任何效果
什么是ASP.NET Identity的IUserSecurityStampStore <TUser>接口?
更新:这是我的Cookie验证设置:
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = DefaultAuthenticationTypes.ApplicationCookie,
LoginPath = new PathString("/Account/Login"),
Provider = new CookieAuthenticationProvider
{
OnValidateIdentity = SecurityStampValidator.OnValidateIdentity<ApplicationUserManager, ApplicationUser>(
validateInterval: TimeSpan.FromSeconds(0),
regenerateIdentity: (manager, user) => user.GenerateUserIdentityAsync(manager)),
OnApplyRedirect = ctx =>
{
if (!IsApiRequest(ctx.Request))
{
ctx.Response.Redirect(ctx.RedirectUri);
}
}
}
});
Run Code Online (Sandbox Code Playgroud)
我可以看到user.GenerateUserIdentityAsync(manager)仅在登录时被命中.