title: C# Cast FormData to an Object
body: <p>I'm posting a file and a json object to my API using angularjs. I'm able to get all the data from the server (file and model object): </p>
  
  <pre><code>public async Task&lt;IHttpActionResult&gt; send()
  {
      var path = HttpContext.Current.Server.MapPath("~/uploads");
      var provider = new MultipartFormDataStreamProvider(root);
      var result = await Request.Content.ReadAsMultipartAsync(provider);
      var modelFromClient = result.FormData["model"];
  }
  </code></pre>
  
  <p>The modelFromClient i receive has this format : <code>"model":"{\"name\":\"James\",\"comments\":\"test\"}</code></p>
  
  <p>But i want to cast the <strong>modelFromClient</strong> json to my user model which is :</p>
  
  <pre><code>public User {
      public string name{ get; set; }   
      public string comments{ get; set; }
  }
  </code></pre>
  
  <p>So at the end, i want to be able to get my attributes like i used to do when i send the object explicitly trought the url : </p>
  
  <pre><code>public async Task&lt;IHttpActionResult&gt; add(User user) {
  
    // here, my user object will have all the values that i set in my client side and i get them like this : 
      user.name;
      user.comments;
      ...// other attributes
      // Save the object in dataBase
      user.Save();
  }
  </code></pre>
  
  <p>I hope you understand my need</p>