Not getting the correct User ID core.net

0

I'm using ASP.NET CORE 2.0, and I'm having to get the user ID logged in. This is my Account Controller:

[Route("[controller]/[action]")]
public class AccountController : Controller
{
    private readonly SignInManager<ApplicationUser> _signInManager;
    private readonly ILogger _logger;
    private readonly UserManager<ApplicationUser> _userManager;

    public AccountController(SignInManager<ApplicationUser> signInManager, ILogger<AccountController> logger, UserManager<ApplicationUser> userManager)
    {
        _signInManager = signInManager;
        _logger = logger;
        _userManager = userManager;
    }

    [HttpPost]
    [ValidateAntiForgeryToken]
    public async Task<IActionResult> Logout()
    {
        await _signInManager.SignOutAsync();
        _logger.LogInformation("User logged out.");
        return RedirectToPage("./Index");
    }


}

I'm trying to get the id this way:

 ApplicationUser a = new ApplicationUser();
            CR.FuncionarioId =  a.Id;

However, this is the id that is in the database:

  

5e7d4078-6388-43e5-8dac-4378f5b366bc

But he's returning me a completely different id, why is this happening? I use Identity. Then when I use a.Id, every hour I immediately, even though it is with the same user, it brings a different Id, and it is not bringing the Id that is registered in the AspnetUsers table.

    
asked by anonymous 12.07.2018 / 14:11

0 answers