title: Asp Core Identity, How to get userId after login?
body: <p>I have 2 controllers named : <code>AdminProfileController</code> And <code>UserProfileController</code>. I want get userId and user role directly after logged in because i want user go to <code>AdminProfileController</code> if user had <code>Admin Role</code> and go to <code>UserProfileController</code> if user had <code>User Role</code>.</p>
  
  <p><strong>My Code</strong></p>
  
  <pre><code>    [HttpPost]
      [AllowAnonymous]
      [ValidateAntiForgeryToken]
      public async Task&lt;IActionResult&gt; Login(LoginViewModel model, string returnUrl = null)
      {
          ViewData["ReturnUrl"] = returnUrl;
          if (ModelState.IsValid)
          {
              var result = await _signInManager.PasswordSignInAsync(model.UserName, model.Password, model.RememberMe, lockoutOnFailure: false);
  
              if (result.Succeeded)
              {
                  return RedirectToLocal(returnUrl);
              }
              else
              {
                  ModelState.AddModelError(string.Empty, "Model Erroe");
                  return View(model);
              }
          }
          return View(model);
      }
  
  
      private IActionResult RedirectToLocal(string returnUrl)
      {
          if (Url.IsLocalUrl(returnUrl))
          {
              return Redirect(returnUrl);
          }
          else
          {
              if (User.IsInRole("Admin"))
              {
                  return Redirect("/AdminProfile/Index");
              }
              else
              {
                  return Redirect("/UserProfile/Index");
              }
          }
      }
  </code></pre>
  
  <p>But <code>User.IsInRole("Admin")</code> always is <code>false</code>, I also tried to get the <code>userId</code> by this code :</p>
  
  <pre><code> string userId = _userManager.GetUserId(HttpContext.User);
  </code></pre>
  
  <p>But it returns also null .
  How can i get <code>userId</code> or <code>role</code> directly after logged in to navigate to Specified path?</p>