I have an application with the following layout. In the General _Layout.cshtml , I have _Layout.cshtml , _SideNav.cshtml and _CurrentUser.cshtml .
In _Layout.cshtml , I have:
@{ Html.RenderPartialIf("_SideNav", Request.IsAuthenticated); }
In _SideNav.cshtml , I have:
@{ Html.RenderPartial("_CurrentUser"); }
In _CurrentUser.cshtml , I have:
<div class="login-info"> <span> <a href="javascript:void(0);" id="show-shortcut" data-action="toggleShortcut"> <img src="~/content/img/avatars/sunny.png" alt="me" class="online" /> <span>@User.Identity.Name</span> <i class="fa fa-angle-down"></i> </a> </span> </div>
We use FormsAuthentication to authenticate the user. We do not use the standard Identity authentication that comes with ASP.Net MVC 5 because we use an LDAP server.
FormsAuthentication.SetAuthCookie(username, isPersistent); ..... HttpContext.Current.User = new GenericPrincipal(new GenericIdentity(username, "Forms"), roles);
We use the username in the cookie so that we can easily receive information from the LDAP server.
Problem: @User.Identity.Name returns this username. But I need to display the full username. I have access to the full name during authentication. but not sure how to use it.
How to pass the FullName value from the AccountController part to a partial view of _CurrentUser.cshtml ? Like a global container like @User.Identity with a lot of attributes that can be set.