There are many topics on this issue, did not found one to fit my wish.
In MVC5, in _LoginPartial
, there is this function User.Identity.GetUserName()
, which is displaying the UserName of the actual user.
I want to display the Name, from ApplicationUser, which contain the properties:
public ApplicationUser()
{
Name = FirstName + " " + LastName;
}
public FirstName {get;set;}
public LastName {get;set;}
public Name {get;}
I have the posibility to use a static function to get the Name, like:
function.Name(User.Identity.GetUserId())
.
I do not want to query again the database, I want to use this User.Identity.Name
, but this function is returning the UserName, I need to override somehow.
How can I get the Name, using User.Identity.Name
?