Answers for "get current logged in user asp net core web api"

C#
4

asp.net core identity get user id

public async Task<IActionResult> YourMethodName()
    {
        var userId =  User.FindFirstValue(ClaimTypes.NameIdentifier) // will give the user's userId
        var userName =  User.FindFirstValue(ClaimTypes.Name) // will give the user's userName

        ApplicationUser applicationUser = await _userManager.GetUserAsync(User);
        string userEmail = applicationUser?.Email; // will give the user's Email
    }
Posted by: Guest on October-07-2020
0

dotnet core 3.1 get the user that just logged in

private Task<ApplicationUser> GetCurrentUserAsync() => _userManager.GetUserAsync(HttpContext.User);
Posted by: Guest on December-07-2020

Code answers related to "get current logged in user asp net core web api"

C# Answers by Framework

Browse Popular Code Answers by Language