In ASP.Net MVC 5 , ApplicationUser can be extended to have a custom property. I expanded it so that now it has a new DisplayName property:
I also updated the database table using the Update-Database command in the Package-Manager Console in Visual Studio to ensure consistency between the ApplicationUser class and AspNetUsers . I confirmed that a new column named DisplayName now exists in the AspNetUsers table.

Now I want to use this DisplayName instead of the standard UserName for the text in the original _LoginPartial.cshtml View . But as you can see:
<ul class="nav navbar-nav navbar-right"> <li> @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" }) </li> <li><a href="javascript:document.getElementById('logoutForm').submit()">Log off</a></li> </ul>
The original _LoginPartialView.cshtml uses User.Identity.GetUserName() to get the UserName ApplicationUser . User.Identity has GetUserId as well as Name , AuthenticationType , etc. But how do I get my DisplayName to display?
Ian Aug 09 '16 at 9:23 2016-08-09 09:23
source share