title: Claims added to ClaimsIdentity getting lost in ASP.NET Core Identity System
body: <p>In my <strong>ASP.NET Core Identity</strong> I have noticed that my claim that I add are <strong>getting lost</strong>. </p>
  
  <p>First I have a Create claim view having a form to create a claim. The <strong>claim is added to the currently logged in user</strong>. </p>
  
  <p>The code of the Action method is:</p>
  
  <pre><code>[HttpPost]
  [ActionName("Create")]
  public IActionResult Create_Post(string claimType, string claimValue, string claimIssuer)
  {
      ClaimsIdentity identity = User.Identity as ClaimsIdentity;
      Claim claim = new Claim(claimType, claimValue, ClaimValueTypes.String, claimIssuer);
      identity.AddClaim(claim);
      return RedirectToAction("Index");
  }
  </code></pre>
  
  <p>The clain is added on this line - <code>identity.AddClaim(claim);</code>.</p>
  
  <p>Now the last line is redirecting to Index action method whose code is:</p>
  
  <pre><code>public ViewResult Index() =&gt; View(User?.Claims);
  </code></pre>
  
  <p>The Index View which is showing all the claim for the user is:</p>
  
  <pre><code>@model IEnumerable&lt;System.Security.Claims.Claim&gt;
  &lt;table class="table table-sm table-bordered"&gt;
      &lt;tr&gt;
          &lt;th&gt;Subject&lt;/th&gt;
          &lt;th&gt;Issuer&lt;/th&gt;
          &lt;th&gt;Type&lt;/th&gt;
          &lt;th&gt;Value&lt;/th&gt;
      &lt;/tr&gt;
  
      @foreach (var claim in Model.OrderBy(x =&gt; x.Type))
      {
          &lt;tr&gt;
              &lt;td&gt;@claim.Subject.Name&lt;/td&gt;
              &lt;td&gt;@claim.Issuer&lt;/td&gt;
              &lt;td&gt;@claim.Type&lt;/td&gt;
              &lt;td&gt;@claim.Value&lt;/td&gt;
          &lt;/tr&gt;
      }
  &lt;/table&gt;
  </code></pre>
  
  <p>Example: I added a claim, see the below image
  <a href="https://i.stack.imgur.com/R3wZW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/R3wZW.png" alt="enter image description here"></a></p>
  
  <p>But the Index View did not fetched the claim, see the below image:
  <a href="https://i.stack.imgur.com/kCQu7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kCQu7.png" alt="enter image description here"></a></p>
  
  <p>What is wrong?</p>