title: Get user.Identity.GetUserId() always null
body: <p>I am using asp.net membership. I have login successfully but when I have access user than user.Identity.GetUserId() always null.</p>
  
  <p>this is my login code.</p>
  
  <pre><code>var signinManager = Context.GetOwinContext().GetUserManager&lt;ApplicationSignInManager&gt;();
  SignInStatus result = signinManager.PasswordSignIn(txtEmail.Text, txtPassword.Text, RememberMe.Checked, false);
  
  switch (result)
  {
      case SignInStatus.Success:
          string strReturnUrl = Request.QueryString["ReturnUrl"] ?? "";
  
          if (string.IsNullOrWhiteSpace(strReturnUrl))
          {
              if (GenericMethods.CheckUserInRole(user, UserRoles.SystemAdmin.ToString()))
                  strReturnUrl = "~/Admin/SettingsMaster.aspx";
              else if (GenericMethods.CheckUserInRole(user, UserRoles.Admin.ToString()))
                  strReturnUrl = "~/Admin/SettingsMaster.aspx";
              else if (GenericMethods.CheckUserInRole(user, UserRoles.CorporateSponsor.ToString()))
                  strReturnUrl = "~/";
              else if (GenericMethods.CheckUserInRole(user, UserRoles.Advertiser.ToString()))
              {
  
                  int productcount = ProductBL.GetInactiveProductCount(user.Id);
                  if (String.IsNullOrEmpty(user.FirstName) || String.IsNullOrEmpty(user.LastName) ||
                                  String.IsNullOrEmpty(user.Address1) || String.IsNullOrEmpty(user.PhoneNumber) ||
                                  String.IsNullOrEmpty(user.Email) || String.IsNullOrWhiteSpace(user.Birthdate.ToString()))
                  {
                      strReturnUrl = "~/MyAccount/ProfileSetting.aspx";
                  }
                  else if (productcount &gt; 0)
                  {
                      strReturnUrl = "~/MyAccount/ViewFeatureProduct.aspx";
                  }
                  else
                      strReturnUrl = "~/MyAccount/AdvertiserTutorial.aspx";
  
              }
              else if (GenericMethods.CheckUserInRole(user, UserRoles.Subscriber.ToString()))
              {
                  int productcount = ProductBL.GetInactiveProductCount(user.Id);
                  if (String.IsNullOrEmpty(user.FirstName) || String.IsNullOrEmpty(user.LastName) ||
                      String.IsNullOrEmpty(user.Address1) || String.IsNullOrEmpty(user.PhoneNumber) ||
                      String.IsNullOrEmpty(user.Email) || string.IsNullOrWhiteSpace(user.Birthdate.ToString()))
                  {
                      strReturnUrl = "~/MyAccount/ProfileSetting.aspx";
                  }
                  else if (productcount == 0)
                  {
                      strReturnUrl = "~/MyAccount/TradeMyStuff.aspx";
                  }
                  else
                      strReturnUrl = "~/";
              }
          }
          var userLoginInfo = new UserLoginInfo("ClosetAuctions.com", "CA");
          userManager.AddLogin(user.Id, userLoginInfo);
  
          user.LastLoginDate = DateTime.Now;
          userManager.Update(user);
  
          IdentityHelper.RedirectToReturnUrl(strReturnUrl, Response);
          break;
      case SignInStatus.LockedOut:
          Response.Redirect("/Account/Lockout");
          break;
      case SignInStatus.RequiresVerification:
          Response.Redirect(
              String.Format("/Account/TwoFactorAuthenticationSignIn?ReturnUrl={0}&amp;RememberMe={1}",
                  Request.QueryString["ReturnUrl"],
                  RememberMe.Checked),
              true);
          break;
      // ReSharper disable once RedundantCaseLabel
      case SignInStatus.Failure:
      default:
          FailureText.Text = "Invalid login attempt";
          ErrorMessage.Visible = true;
          break;
  }
  </code></pre>
  
  <p>I am getting <code>userId</code> here.</p>
  
  <pre><code>public static ApplicationUser GetCurrentUser()
  {
      var user = HttpContext.Current.User;
  
      if (user == null) return null;
      if (user.Identity.GetUserId() == null) return null;
  
  
  
      var db = new MyDbContext();
      var manager = new UserManager&lt;ApplicationUser&gt;(new UserStore&lt;ApplicationUser&gt;(db));
      return manager.FindById(user.Identity.GetUserId());
  
      //   manager.AddClaim(CurrentUser.Id, new Claim(ClaimTypes.Role, "systemAdmin"));
      //   manager.AddClaim(CurrentUser.Id, new Claim(ClaimTypes.Role, "admin"));                
  }
  </code></pre>
  
  <p>I am not sure, where I am wrong.</p>
  
  <p>If any one know then Can you please help me.</p>