📅  最后修改于: 2022-03-11 14:49:05.188000             🧑  作者: Mango
You should use identity to add or remove a claim. Try this to add a claim.
var user = User as ClaimsPrincipal;
var identity = user.Identity as ClaimsIdentity;
identity.AddClaim(new Claim(ClaimTypes.Role, "somenewrole"));
To remove a claim,
var user = User as ClaimsPrincipal;
var identity = user.Identity as ClaimsIdentity;
var claim = (from c in user.Claims
where c.Value == "somenewrole"
select c).Single();
identity.RemoveClaim(claim);
BTW, it is better to use User from your controller instead of HttpContext.Current.User.