title: Claims GetUserId is null
body: <p>I hope you're all great, this time I'm here to ask an issue that I can't figure it out and it's about Identity, the thing is I want to get de User Id from the Claims principal or whereever it is, right now the only thing that I have is </p>
  
  <pre><code>var principal = ClaimsPrincipal.Current;
          var id1 = principal.Claims.FirstOrDefault(c =&gt; c.ValueType == ClaimTypes.NameIdentifier);
  </code></pre>
  
  <p>but when I try to get the UserId and I go to the information inside the claims I can't find the value even if I saved it in the AuthorizationTicket at login.</p>
  
  <p>I'm working with MVC template and Web api service My service is hosted in IIS and with it I manage the authentication with an accountcontroller via Token </p>
  
  <p>this is my AuthenticationProperties</p>
  
  <pre><code>public static AuthenticationProperties CreateProperties(string userName, string userid)
      {
          IDictionary&lt;string, string&gt; data = new Dictionary&lt;string, string&gt; { { "userName", userName }, { "userId", userid } };
          return new AuthenticationProperties(data);
      }
  </code></pre>
  
  <p>and my GrantResourceOwnerCredentiales</p>
  
  <pre><code>public override async Task GrantResourceOwnerCredentials(OAuthGrantResourceOwnerCredentialsContext context)
      {
          var userManager = context.OwinContext.GetUserManager&lt;ApplicationUserManager&gt;();
          //var userManager = DependencyResolver.Current.GetService&lt;ApplicationUserManager&gt;();
  
          AppJobSeeker user = await userManager.FindAsync(context.UserName, context.Password);
  
          if (user == null)
          {
              context.SetError("invalid_grant", "The user name or password is incorrect.");
              return;
          }
  
          ClaimsIdentity oAuthIdentity = await user.GenerateUserIdentityAsync(userManager, OAuthDefaults.AuthenticationType);
          ClaimsIdentity cookiesIdentity = await user.GenerateUserIdentityAsync(userManager, CookieAuthenticationDefaults.AuthenticationType);
  
          AuthenticationProperties properties = CreateProperties(user.UserName, user.Id);
          AuthenticationTicket ticket = new AuthenticationTicket(oAuthIdentity, properties);
          context.Validated(ticket);
          context.Request.Context.Authentication.SignIn(cookiesIdentity);...
  </code></pre>
  
  <p>And I have a method which creates a AuthenticationTicket and it receive the UserName and the UserId as well </p>
  
  <pre><code>private void CreateTicket(SignInResult result, SignInModel model, string returnUrl)
      {
          //Let's keep the user authenticated in the MVC webapp.
          //By using the AccessToken, we can use User.Identity.Name in the MVC controllers to make API calls.
          FormsAuthentication.SetAuthCookie(result.AccessToken, model.RememberMe);
  
          //Create an AuthenticationTicket to generate a cookie used to authenticate against Web API.
          //But before we can do that, we need a ClaimsIdentity that can be authenticated in Web API.
          var claims = new[]
          {
              new Claim(ClaimTypes.Name, result.UserName), //Name is the default name claim type, and UserName is the one known also in Web API.
              new Claim(ClaimTypes.NameIdentifier, result.UserId), //If you want to use User.Identity.GetUserId in Web API, you need a NameIdentifier claim.
          };
  
          //Generate a new ClaimsIdentity, using the DefaultAuthenticationTypes.ApplicationCookie authenticationType.
          //This also matches what we've set up in Web API.
          var authTicket = new AuthenticationTicket(new ClaimsIdentity(claims, DefaultAuthenticationTypes.ApplicationCookie), new AuthenticationProperties
          {
              ExpiresUtc = result.Expires,
              IsPersistent = model.RememberMe,
              IssuedUtc = result.Issued,
              RedirectUri = returnUrl
          });
  </code></pre>
  
  <p>...</p>
  
  <p>Everithing looks fine when I do the login but when a I go to another controller  I can't retreive the UserId</p>