title: How to inject the value from claim to data transfer object in asp net core?
body: <p>For example:
  I have a dto as an action parameter with from body attribute</p>
  
  <pre><code>public IActionResult Bar([FromBody]Foo dto)
  {
    var claimsIdentity = User.Identity as ClaimsIdentity;
    var uid = Convert.ToInt32(claimsIdentity.Claims.FirstOrDefault(c =&gt; c.Type == "sub")?.Value);
    dto.uid = uid;
    _barService(dto);
    return Ok();           
  }
  public class Foo
  {
    public int uid {get;set;} // from claim
    public string something{get;set;} // from front end request
  }
  </code></pre>
  
  <p>Currently,I have the write code to provide the claim value to the dto manually</p>
  
  <p><strong>Q: In asp net core, how can I inject the claim value to the dto automatically?</strong></p>