Search code examples
identityserver4

Cannot get username in client MVC app


I have 2 projects, one is the identity server 4 and one is the client AspNetCore MVC. On client app, how I can get the current user name or current user email ? More specific, I would like to put it on _Layout.cshtml .

Thank you, Mihai


Solution

  • You can make a rest call to the server and have it return the authorized user. Make sure you have the correct claims.

    Get current user name in IdentityServer4 & ASP.net Core

    For the official docs to getting user info check here: http://docs.identityserver.io/en/release/endpoints/userinfo.html