title: How do I get dynamic properties from OkObjectResult
body: <p>I return <code>IActionResult</code> with the value of an anonymous object from a controller method.<br>
  How do I get the data out again?</p>
  
  <p>Here is the controller method reduced to the very problem:</p>
  
  <pre><code>[HttpPost]
  public async Task&lt;IActionResult&gt; UploadFile(IFormFile file)
  {
      long size = file.Length;
      return Ok(new { count = 1, size });
  }
  </code></pre>
  
  <p>Then I get the <code>.Value</code> property, which is an <code>object</code> and make it <code>dynamic</code>.<br>
  But no, it is not recognised.</p>
  
  <pre><code>[Fact]
  public async Task UploadFileTest()
  {
      //  #   Given.
      var formFile = new Mock&lt;IFormFile&gt;();
      var sut = new HomeController(null);
  
      //  #   When.
      IActionResult result = await sut.UploadFile(formFile.Object);
  
      //  #   Then.
      OkObjectResult okResult = (OkObjectResult)result; // Ok.
      dynamic dynValue = okResult.Value; // Ok.
      var count = dynValue.count; // Not ok.
  }
  </code></pre>
  
  <p>Expected result:</p>
  
  <p><code>count</code> should be 1.</p>
  
  <p>Actual result:</p>
  
  <blockquote>
    <p>Microsoft.CSharp.RuntimeBinder.RuntimeBinderException : 'object' does not contain a definition for 'count'</p>
  </blockquote>