Search code examples
c#asp.net-mvcasp.net-identity-2asp.net-core-mvc

Get ApplicationUser from Partial View


I have asked similar question about older MVC version and Membership, but those solutions don't work with Idendity and MVC 6.
I want to display user's first name inside _LoginPartial.cshtml file. So, instead of "Hello " + User.Identity.GetUserName() + "!" I want to access ApplicationUser.FirstName for the currently logged in user. What is the best way to do this?


Solution

  • I have found another solution, implementing custom IPrincipal. I think it's the best, cause it doesn't require user search every time I need that info.