How to access a specific claim in claim aware application RRS feed

  • Question

  • User1315728448 posted

    Hello I ahave a claim aware application and i am using sts to send the claims.

    currently i am accessing the claims as

    but i want to access a perticular claim and dont want to access it by the position.
    I want to access it something like this


    Does anybody know how to do it.

    please help me to find the proper solution.
    Friday, August 17, 2012 2:48 AM


  • User1779161005 posted

    Use LINQ:

    var nameClaimQuery =

         from c in Identity.Claims

        where c.ClaimType == ClaimsTypes.Name

        select c;

    var nameClaim = nameClaimQuery.FirstOrDefault();

    if (nameClaim != null) var name = nameClaim.Value;

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, August 17, 2012 10:48 AM