2
我在一个asp.net项目中工作,我需要更新身份声明的值。如何更新ASP.NET Identity 3.0中的声明?
我读:
How to update a claim in ASP.NET Identity?
我想要做的类似,但在身份3.0的东西。
我在一个asp.net项目中工作,我需要更新身份声明的值。如何更新ASP.NET Identity 3.0中的声明?
我读:
How to update a claim in ASP.NET Identity?
我想要做的类似,但在身份3.0的东西。
尝试这样?
var identity = new ClaimsIdentity(User.Identity);
identity.RemoveClaim(identity.FindFirst("name"));
identity.AddClaim(new Claim("name", "Jon"));
var authenticationManager = HttpContext.GetOwinContext().Authentication;
authenticationManager.AuthenticationResponseGrant = new AuthenticationResponseGrant(
new ClaimsPrincipal(identity),
new AuthenticationProperties
{
IsPersistent = true
});