Developing ASP.NET MVC Web Applications — Question 118

You develop an ASP.NET MVC application. The application is configured for claims-based authentication by using Windows Identity Foundation (WIF).
You need to access the claims in the WIF token.
Which code segment should you use?

Answer options

Correct answer: B

Explanation

The correct answer is B because it explicitly casts the current principal to IClaimsPrincipal and accesses the claims of the first identity. Option A only retrieves the identity without accessing the claims, while option C retrieves the current principal without any specific details about claims. Option D checks if the identity is authenticated but does not provide access to the claims themselves.