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