Answers for ".net core usermanager get current user"

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
1

.net core check if user is logged in

@if(!User.Identity.IsAuthenticated) 
{
    ...
}
Posted by: Guest on October-21-2021

C# Answers by Framework

Browse Popular Code Answers by Language