Skip to content

Instantly share code, notes, and snippets.

@jonocairns
Created December 12, 2016 19:58
Show Gist options
  • Save jonocairns/68b39deb4914a34391da3ea8b9361925 to your computer and use it in GitHub Desktop.
Save jonocairns/68b39deb4914a34391da3ea8b9361925 to your computer and use it in GitHub Desktop.
get claim identity
IPrincipal currentUser = HttpContext.Current.User;
var identity = User.Identity as ClaimsIdentity;
string claims = string.Empty;
if (identity != null)
foreach (Claim identityClaim in identity.Claims)
{
claims += $"{identityClaim.Subject.Name}:{identityClaim.Type}:{identityClaim.Value},";
}
string identityName = currentUser.Identity.Name;
return $"Hello {identityName}! claim: {claims}";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment