Reputation: 265
I am working in a asp.net project and i need to update the value of a identity claim.
I read:
How to update a claim in ASP.NET Identity?
I want to do something similar but in Identity 3.0.
Upvotes: 2
Views: 841
Reputation: 7430
try something like this?
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
});
Upvotes: 1