Model binding issue with multipart forms using Win8 RP HttpClient

Topics: ASP.NET MVC
Jun 21, 2012 at 10:07 PM

Not sure if this is the fault of Win8 HttpClient or MVC4 RC model binder but it appears that the model binder doesn't bind Multipart Form Data when sent using the Win8 HttpClient with MultipartFormDataContent. Taking a look at the fiddler capture between IE10 and Win8 HttpClient:

IE 10

POST http://app.test.com/api/v1/logs HTTP/1.1
Content-Type: multipart/form-data; boundary="6ff1459c-1e14-4e16-835c-0f60bc6360d8"
Host: app.test.com
Content-Length: 170
Expect: 100-continue
Connection: Keep-Alive

--6ff1459c-1e14-4e16-835c-0f60bc6360d8
Content-Disposition: form-data; name="ApiKey"

527535aa-9a70-4c4b-acf4-9680429a8197
--6ff1459c-1e14-4e16-835c-0f60bc6360d8--

Win8 HttpClient

POST http://app.test.com/api/v1/logs HTTP/1.1
Content-Type: multipart/form-data; boundary="49291003-bea3-4af8-b747-ad5b53cc8feb"
Host: app.test.com
Content-Length: 168
Expect: 100-continue
Connection: Keep-Alive

--49291003-bea3-4af8-b747-ad5b53cc8feb
Content-Disposition: form-data; name=ApiKey

527535aa-9a70-4c4b-acf4-9680429a8197
--49291003-bea3-4af8-b747-ad5b53cc8feb--

The only apparent difference is that the HttpClient in Win8 isn't setting the name property in the Content-Disposition header as a quoted string. Which is causing the model binder to ignore the property.