title: Mvc Identity Longin ClaimsPrincipal value always null
body: <p>This is my Login controller</p>
  
  <pre><code>public class AccountController : BaseController
  {
      [HttpPost]
      [AllowAnonymous]
      [ValidateAntiForgeryToken]
      public ActionResult Login(LoginViewModel model, string returnUrl)
      {                                         
        var identity = new ClaimsIdentity(new[] 
        {
           new Claim(ClaimTypes.Name, "Huang"),
           new Claim(ClaimTypes.NameIdentifier, user.Vaild.ToString()),
           new Claim(ClaimTypes.Email,"xxx@gmail.com"),
           new Claim(ClaimTypes.MobilePhone,"123456"), 
        },DefaultAuthenticationTypes.ApplicationCookie);
  
  
    IdentityTool.Authentication(AuthenticationManager,identity,rememberMe:true);
  
       // userEmail and userPhone  always null and I got null exception
          var userEmail = CurrentUser.Email;
          var userPhone = CurrentUser.MobilePhone;  
  
      return View(model);
     }
  }
  
  public class BaseController : Controller
  {
      public AppUser CurrentUser
      {
          get { return new AppUser(this.User as System.Security.Claims.ClaimsPrincipal);}
  
      }
  }
  </code></pre>
  
  <p>IdentityConfig</p>
  
  <pre><code>public class IdentityTool
  {
   public static void Authentication(IAuthenticationManagerauthenticationManager, ClaimsIdentity identity, bool rememberMe)
       {
          if (rememberMe)
          {
              authenticationManager.SignIn(new AuthenticationProperties()
              {
                  IsPersistent = true,
                  ExpiresUtc = DateTimeOffset.UtcNow.AddDays(14)
              }, identity);
          }
          else
          {
              authenticationManager.SignIn(new AuthenticationProperties()
              {
                  IsPersistent = false
              }, identity);
          }
      }
  }
  
  //Custom property
  public class AppUser : ClaimsPrincipal
  {        
      public AppUser(ClaimsPrincipal principal) : base(principal)
      {
      }
      public string Email
      {
          get
          {
              return this.FindFirst(ClaimTypes.Email).Value;
          }
      }
  
      public string MobilePhone
      {
          get
          {
              return this.FindFirst(ClaimTypes.MobilePhone).Value;
          }
      }
   }
  </code></pre>
  
  <p>This is my  Startup</p>
  
  <pre><code>public void ConfigureAuth(IAppBuilder app)
  {
      AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;                     
      app.UseCookieAuthentication(new CookieAuthenticationOptions
      {
          AuthenticationType =DefaultAuthenticationTypes.ApplicationCookie, 
          LoginPath = new PathString("/Account/Login"),
          Provider = new CookieAuthenticationProvider
          {
  
              OnValidateIdentity = SecurityStampValidator.OnValidateIdentity&lt;ApplicationUserManager, ApplicationUser&gt;(
                  validateInterval: TimeSpan.FromMinutes(30),
                  regenerateIdentity: (manager, user) =&gt; user.GenerateUserIdentityAsync(manager))
          }
      });            
      app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
  </code></pre>
  
  <p>Then I got null exception on "CurrentUser.Email" and "CurrentUser.MobilePhone" always null. Please help me to fix it. I really appreciate. I ask many people but no one can fix it.If you have some suggest to modify some code.May helpful.Please let me know.blow picture is my exception detail. Sorry for some Chinese in the picture.^^</p>
  
  <p><a href="https://i.stack.imgur.com/j8d3b.png" rel="nofollow noreferrer">This is my exception detail hope help</a></p>