title: User.Identity.GetUserId() returns null after successful login
body: <p>I've defined a temp variable to get current user id, it always returns null.</p>
  
  <p>Here is the snapshot:</p>
  
  <p><a href="https://i.stack.imgur.com/PebtZ.png" rel="noreferrer"><img src="https://i.stack.imgur.com/PebtZ.png" alt="userId"></a></p>
  
  <p>Why?</p>
  
  <p><strong>UPDATE:</strong></p>
  
  <pre><code>    //
      // POST: /Account/Login
      [HttpPost]
      [AllowAnonymous]
      public async Task&lt;ActionResult&gt; Login(LoginViewModel model, string returnUrl)
      {
          if (!ModelState.IsValid)
          {
              return Json(new { success = false, ex = "Fail to login." });
          }
  
          var result = await SignInManager.PasswordSignInAsync(model.Email, model.Password, isPersistent: true, shouldLockout: false);
          switch (result)
          {
              case SignInStatus.Success:
                  string userId = User.Identity.GetUserId();
                  return Json(new { success = true });
              case SignInStatus.Failure:
                  return Json(new { success = false, ex = "Email or password was incorrect." });
              default:
                  return Json(new { success = false, ex = "Fail to login." });
          }
      }
  </code></pre>
  
  <p><strong>UPDATE 2:</strong></p>
  
  <p>On client side, I use ajax to connect to <code>/Account/Login</code>:</p>
  
  <pre><code>var loginAjax = function (email, password, callback) {        
          $.ajax({
              url: '/Account/Login',
              type: 'POST',
              data: { Email: email, Password: password },
              success: function (data) {
                  $('body').css('cursor', 'default');
                  if (data.success) {                    
                      callback(true)
                  } else {
                      $('#login-error').text(data.ex)
                  }
              },
              error: function () {                
                  $('#login-error').text('Không thể kết nối đến máy chủ.')
              }
          });
          callback(false)
      };
  
  
  // I've got email and password in another function to check valid or not
  loginAjax(email, password, function (success) {
              $('body').css('cursor', 'default');
              switch (success) {
                  case true:
                      signin(function () {
                          $('.login').html('');
                          window.location.href = '/?type=Promotion';
                      });
                      break
                  case false:                    
                      $('#Email-active').hide();
                      $('#Password-active').hide();
                      $('#Password').val('');
                      $('#login-btn').removeClass('disabled').attr('onclick', '$(this).addClass("disabled").removeAttr("onclick"); running()');
                      break
              }
          });
  </code></pre>
  
  <p>SignalR on client side:</p>
  
  <pre><code>var signalR = $.connection.chat;
  var signin = function (callback) {
              $.connection.hub.start().done(function () {
                  signalR.server.signinToSignalR();
                  callback()
              })
          };
  </code></pre>
  
  <p>SignalR on server side:</p>
  
  <pre><code>public void SigninToSignalR()
      {
          // this's always null
          string userId = HttpContext.Current.User.Identity.GetUserId();
      }
  </code></pre>