I had the same problem. Solved by MultipartDataMediaFormatter for ASP.NET WebApi. How to use:
- Find and install from Nuget packages MultipartDataMediaFormatter.
-
Add current formatter to WebApi formatters collection:
- if WebApi hosted on IIS (on Application Start). :
GlobalConfiguration.Configuration.Formatters.Add(new FormMultipartEncodedMediaTypeFormatter());
-
if WebApi is self-hosted:
new HttpSelfHostConfiguration(<url>).Formatters.Add(new FormMultipartEncodedMediaTypeFormatter());
- if WebApi hosted on IIS (on Application Start). :
After that you can post objec with file together in one model.
Note: In Nuget packages version 1.1.0 is not the last. They are not updated yet. Maybe possible to install latest version manually.