TryRemoveClaim() public method

It is possible that a Claim returned from Claims cannot be removed. This would be the case for 'External' claims that are provided by reference.

object.ReferenceEquals is used to 'match'.

public TryRemoveClaim ( Claim claim ) : bool
claim Claim the to match.
return bool
コード例 #1
0
 public static void ReplaceClaim(this ClaimsIdentity identity, string type, string value)
 {
     identity.TryRemoveClaim(identity.Claims.FirstOrDefault(c => c.Type == type));
     identity.AddClaim(new Claim(type, value));
 }