2

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.

Community
  • 1
  • 1
Johan Pino
  • 227
  • 1
  • 2
  • 13

1 Answers1

1

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
    });
Naeem Sarfraz
  • 7,360
  • 5
  • 37
  • 63