title: Web API Simplest way to pickup a multipart/form-data response
body: <p>I have a problem but I cannot see what I'm doing wrong ?
  I want to make the simplest method possible to get this to work I will make it more complex later but currently just want the post method to be hit I don't even care if the code inside is working currently.</p>
  
  <p>only thing I care about is that it sends a OK 200 reply back.</p>
  
  <p>Currently I either get a internal server error 500 response or a 405 method not allowed response depending on if I try to send data or just force the method call with my browser.</p>
  
  <p>have a IOS app that sends the post request below and I have a test PHP script that proved that this worked. Now I want to move it to the server that should be doing the work on a IIS 8. However I'm struggling with just even making the connection currently:</p>
  
  <pre><code>POST /api/Image/Upload HTTP/1.1
  Host: ServerName
  Content-Type: multipart/form-data; boundary=-------------Boundary----------35042EC1-790C-4CDD-8E21-66E6B1025C2D
  Connection: keep-alive
  Accept: */*
  filename: DefaultPrefix1.jpg
  User-Agent: KameraApp/1 CFNetwork/808.3 Darwin/16.3.0
  Content-Length: 5492253
  Accept-Language: da-dk
  Accept-Encoding: gzip, deflate
  
  ---------------Boundary----------35042EC1-790C-4CDD-8E21-66E6B1025C2D
  Content-Disposition: form-data; name='image'; filename="DefaultPrefix1.jpg"
  Content-Type: image/jpg
  
  Image Data
  End boundary
  </code></pre>
  
  <p>How I'm trying to pick up the above Multipart/form-data:</p>
  
  <pre><code>[RoutePrefix("api/Image")]
  public class ImageController : ApiController
      {
  
          [HttpPost]
          [Route("Upload")]
          public IHttpActionResult Upload()
          {
              var files= HttpContext.Current.Request.Files;
  
              var aFile = files.Get(0);
  
  
              string filename = aFile.FileName;
              string path = @"C:\ImageUploaderService\UploadFolder";
              aFile.SaveAs(path + filename);
              return Ok("Working");
          }
      }
  </code></pre>
  
  <p><strong>Edit:</strong></p>
  
  <p>changed to the current Method based on the suggestion below</p>
  
  <p>my WebApiConfig looks like this:</p>
  
  <pre><code>  public static void Register(HttpConfiguration config)
      {
          // Web API configuration and services
  
          // Web API routes
          config.MapHttpAttributeRoutes();
  
          config.Routes.MapHttpRoute(
              name: "DefaultApi",
              routeTemplate: "api/{controller}/{id}",
              defaults: new { id = RouteParameter.Optional }
          );
  </code></pre>