im using MVC 5 and i found this : User.Identity.Name full name mvc5 , but i dont know how use the "Extension Method on Identity" where i put this code, and where...please help me
Extension Method on Identity:
public static class GenericPrincipalExtensions
{
public static string FullName(this IPrincipal user)
{
if (user.Identity.IsAuthenticated)
{
ClaimsIdentity claimsIdentity = user.Identity as ClaimsIdentity;
foreach (var claim in claimsIdentity.Claims)
{
if (claim.Type == "FullName")
return claim.Value;
}
return "";
}
else
return "";
}
}