title: Claims Authentication ASP.NET vNext
body: <p>When adding a claim to the user, the claims information does not get recorded as a cookie on the page and the information gets lost for all other requests. Why does this happen?</p>
  
  <pre><code>    public async Task&lt;IActionResult&gt; Login(LoginViewModel model, string returnUrl = null)
      {
          if (ModelState.IsValid)
          {
              try
              {
                  var authReq = new AuthenticationViewModel() { password = model.Password, username = model.UserName };
                  var userInfo = await _dataService.AuthenticateAsync(authReq);
  
  
                  var claims = new List&lt;Claim&gt;();
                  claims.Add(new Claim("username", userInfo.user.userName));
                  claims.Add(new Claim("AddtionalData", userInfo.AddtionalData));
  
                  var user = ClaimsPrincipal.Current;
  
                  var identity = user.Identities.Where(x =&gt; x.AuthenticationType == "Custom").FirstOrDefault();
  
                  if (identity == null)
                      identity = new ClaimsIdentity(claims.ToArray(), "Custom");
  
                  user.AddIdentity(identity);
  
  
                  return RedirectToAction("Users", "Index");
              }
              catch (Exception)
              {
                  ModelState.AddModelError("", "Invalid username or password.");
              }
  
          }
  
          // If we got this far, something failed, redisplay form
          return View(model);
      }
  </code></pre>