title: How to upload file AND model using Web API?
body: <p>Basically I'm trying to upload an image along with an enum using Web API 2.</p>
  
  <p>Here's the controller signature:</p>
  
  <pre><code>[HttpPost]
  public UploadResponseVm Upload([FromBody]ResImageType type)
  {
  </code></pre>
  
  <p>The thing is, whenever I try to post a multipart form (with a file and a type) I get a 415 error:</p>
  
  <blockquote>
    <p>{"Message":"The request entity's media type 'multipart/form-data' is
    not supported for this resource.","ExceptionMessage":"No
    MediaTypeFormatter is available to read an object of type
    'ResImageType' from content with media type
    'multipart/form-data'.","ExceptionType":"System.Net.Http.UnsupportedMediaTypeException","StackTrace":"
    at System.Net.Http.HttpContentExtensions.ReadAsAsync[T](HttpContent
    content, Type type, IEnumerable<code>1 formatters, IFormatterLogger
    formatterLogger, CancellationToken cancellationToken)\r\n at
    System.Web.Http.ModelBinding.FormatterParameterBinding.ReadContentAsync(HttpRequestMessage
    request, Type type, IEnumerable</code>1 formatters, IFormatterLogger
    formatterLogger, CancellationToken cancellationToken)"}</p>
  </blockquote>
  
  <p>I have even added the following to my startup.cs class:</p>
  
  <pre><code>    config.Formatters.Insert(0, new System.Net.Http.Formatting.JsonMediaTypeFormatter());
  </code></pre>
  
  <p>How can I upload a model along with a file using a web api controller?</p>