title: How to Get Custom Property Value of the ApplicationUser in the ASP.Net MVC 5 View?
body: <p>In the <code>ASP.Net MVC 5</code>, the <code>ApplicationUser</code> can be extended to have custom property. I have extended it such that it now has a new property called <code>DisplayName</code>:</p>
  
  <pre><code>// You can add profile data for the user by adding more properties to your ApplicationUser class, please visit http://go.microsoft.com/fwlink/?LinkID=317594 to learn more.
  public class ApplicationUser : IdentityUser {
      public string ConfirmationToken { get; set; }
      public string DisplayName { get; set; } //here it is!
  
      public async Task&lt;ClaimsIdentity&gt; GenerateUserIdentityAsync(UserManager&lt;ApplicationUser&gt; manager) {
          // Note the authenticationType must match the one defined in CookieAuthenticationOptions.AuthenticationType
          var userIdentity = await manager.CreateIdentityAsync(this, DefaultAuthenticationTypes.ApplicationCookie);
          // Add custom user claims here
          return userIdentity;
      }
  }
  </code></pre>
  
  <p>I also have updated the database table using <code>Update-Database</code> command in the <code>Package-Manager Console</code> in <code>Visual Studio</code> to ensure the consistency between the <code>ApplicationUser</code> <code>class</code> and the <code>AspNetUsers</code> table. I have confirmed that the new column called <code>DisplayName</code> is now exist in the <code>AspNetUsers</code> table.</p>
  
  <p><a href="https://i.stack.imgur.com/lsf1Y.png" rel="noreferrer"><img src="https://i.stack.imgur.com/lsf1Y.png" alt="enter image description here"></a></p>
  
  <p>Now, I want to use that <code>DisplayName</code> instead of the default <code>UserName</code> for the text in the original <code>_LoginPartial.cshtml</code> <code>View</code>. But as you can see:</p>
  
  <pre><code>&lt;ul class="nav navbar-nav navbar-right"&gt;
    &lt;li&gt;
      @Html.ActionLink("Hello " + User.Identity.GetUserName() + "!", "Index", "Manage", routeValues: null, htmlAttributes: new { title = "Manage" })
    &lt;/li&gt;
    &lt;li&gt;&lt;a href="javascript:document.getElementById('logoutForm').submit()"&gt;Log off&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>
  
  <p>The original <code>_LoginPartialView.cshtml</code> is using <code>User.Identity.GetUserName()</code> to get the <code>UserName</code> of the <code>ApplicationUser</code>. The <code>User.Identity</code> has <code>GetUserId</code> and also <code>Name</code>, <code>AuthenticationType</code>, etc... But how do I get my <code>DisplayName</code> for display?</p>