1 year ago

#320075

test-img

codeninja

Is there a way to return a single Claim value using a key or identifier in a View?

I am accessing all my claims by looping through all of them using a for each statement. I want to be getting a single value using the identifier like below where the name is the identifier.

User.Claims.Type[name]

Currently i am accessing my claims like this and all the values are being returned

if (User.Identity.IsAuthenticated)
{
    foreach(var claim in User.Claims)
    {
        @claim.Value
    }
}

c#

asp.net

claims-based-identity

0 Answers

Your Answer

Accepted video resources