我在asp.net项目中工作,我需要更新身份声明的价值。
我看了:
How to update a claim in ASP.NET Identity?
我想在Identity 3.0中做类似的事情。
答案 0 :(得分:1)
尝试这样的事情?
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
});