I'm able to obtain the user name (email format) of the authenticated user using:
var autenticateduser = HttpContext.User.Identity.Name;
Using QuickWatch window I am able to find the givenname and surname using the following expression. Is there a more clean way to obtain this info?
(new System.Linq.SystemCore_EnumerableDebugView<System.Security.Claims.Claim>(((System.Security.Claims.ClaimsIdentity)(HttpContext.User.Identity)).Claims)).Items[5]
How about
ClaimsPrincipal cp = ClaimsPrincipal.Current;
string welcome = string.Format("Welcome, {0} {1}!", cp.FindFirst(ClaimTypes.GivenName).Value, cp.FindFirst(ClaimTypes.Surname).Value);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With