title: MVC 5 Global User Account Object
body: <p>I have a application with the following Layout. In the Shared Views Folder I have, <code>_Layout.cshtml</code>, <code>_SideNav.cshtml</code> and <code>_CurrentUser.cshtml</code>.</p>
  
  <p>In the <code>_Layout.cshtml</code> I have: </p>
  
  <pre><code>@{ Html.RenderPartialIf("_SideNav", Request.IsAuthenticated); }
  </code></pre>
  
  <p>In the <code>_SideNav.cshtml</code> I have: </p>
  
  <pre><code>@{ Html.RenderPartial("_CurrentUser"); }
  </code></pre>
  
  <p>In the <code>_CurrentUser.cshtml</code> I have:</p>
  
  <pre><code>&lt;div class="login-info"&gt;
      &lt;span&gt;
          &lt;a href="javascript:void(0);" id="show-shortcut" data-action="toggleShortcut"&gt;
              &lt;img src="~/content/img/avatars/sunny.png" alt="me" class="online" /&gt;
              &lt;span&gt;@User.Identity.Name&lt;/span&gt;
              &lt;i class="fa fa-angle-down"&gt;&lt;/i&gt;
          &lt;/a&gt;
      &lt;/span&gt;
  &lt;/div&gt;
  </code></pre>
  
  <p>We use <code>FormsAuthentication</code> to authenticate a user. We are not using the standard <code>Identity</code> authentication which ships with <code>ASP.Net MVC 5</code> because we are using a <code>LDAP</code> Server.</p>
  
  <pre><code>FormsAuthentication.SetAuthCookie(username, isPersistent);
  .....
  HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(username, "Forms"), roles);
  </code></pre>
  
  <p>We use the <code>username</code> in the cookie so that we can easily get information from the <code>LDAP</code> server.</p>
  
  <p>Problem: <code>@User.Identity.Name</code> returns that username. But I need to display the full name of the user. I have access to the full name when we authenticate. but not sure how to use it.</p>
  
  <p>How can I pass the <code>FullName</code> value from the <code>AccountController</code> to the <code>_CurrentUser.cshtml</code> partial view? Kind of like a Global Container like <code>@User.Identity</code> with more attributes that can be set.</p>