title: WebAPI DataMember Name not used when de/serializing via application/x-www-form-urlencoded
body: <p>Already spent couple of hours trying to resolve issue with ignored <code>Name</code> property on <code>DataMemberAttribute</code> when handling HTTP POST form request (<code>Content-Type: application/x-www-form-urlencoded</code>).</p>
  
  <p>I'm having <code>Microsoft.AspNet.WebApi 5.2.3</code> application running on .NET 4.5, hosted by IIS.</p>
  
  <p>I have this model (demo):</p>
  
  <pre><code>// library
  public interface IPayload
  {
      string DataId { get; set; }
      int RelationId { get; set; }
  }
  
  // web app project
  [DataContract]
  public class MyPayload : IPayload
  {
      [Required]
      [DataMember(Name = "id")]
      public string DataId { get; set; }
  
      [Required]
      [DataMember(Name = "rel")]
      public int RelationId { get; set; }
  }
  </code></pre>
  
  <p>Then I have controller:</p>
  
  <pre><code>[HttpPost]
  [Route("~/api/stuff")]
  public async Task&lt;HttpResponseMessage&gt; DoMagic(MyPayload payload)
  {
      // ... breakpoint
  }
  </code></pre>
  
  <p>(Note I'm really using model type and not just interface in my controller)</p>
  
  <hr>
  
  <p>When I send data like this:</p>
  
  <pre><code>curl -X POST --data '{"id":"foo","rel":1}' -H "Content-Type: application/json" -H "Content-Length: 20" http://localhost/api/stuff
  </code></pre>
  
  <p>I get my model deserialized correctly. </p>
  
  <hr>
  
  <p>However, when I do:</p>
  
  <pre><code>curl --data "id=foo" --data "rel=1" http://localhost/api/stuff
  </code></pre>
  
  <p>... I'm getting empty model - custom name is ignored, all properties have default value.</p>
  
  <p>Finally, when I do request like this:</p>
  
  <pre><code>curl --data "DataId=foo" --data "RelationId=1" http://localhost/api/stuff
  </code></pre>
  
  <p>... model is serialized correctly.</p>
  
  <hr>
  
  <p>So I'm wondering, what am I doing wrong. I spent quite a lot of reading, most of cases I found were about missing <code>DataContractAttribute</code> which is present in my case.</p>
  
  <p>Attribute <code>FromBody</code> in front of controller parameter is not changing anything as well.</p>
  
  <p>In my application, these formatters are registered:</p>
  
  <ul>
  <li><code>System.Net.Http.Formatting.JsonMediaTypeFormatter</code></li>
  <li><code>System.Net.Http.Formatting.XmlMediaTypeFormatter</code></li>
  <li><code>System.Net.Http.Formatting.FormUrlEncodedMediaTypeFormatter</code></li>
  <li><code>System.Web.Http.ModelBinding.JQueryMvcFormUrlEncodedFormatter</code></li>
  </ul>
  
  <p>Only last two contain <code>application/x-www-form-urlencoded</code> in <code>SupportedMediaTypes</code>.</p>