2016-06-21 45 views

回答

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 
    });