List All the Claims of the Current User

The easiest way to display all the claims that was issued to the current user is to query the Identity property of the IPrincipal interface.

Here is the sample code in razor view.

@{
    var identity = (System.Security.Claims.ClaimsIdentity)User.Identity;
}

<ul>
    @foreach (var x in identity.Claims)
    {
        <li> claim:@x.Type -> @x.Value</li>
    }

</ul>

Comments