title: Error reading MIME multipart body part. ---> System.Web.HttpException: The client disconnected
body: <p>I'm Trying to pick up this Multipart Post message:</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>This is how I'm currently trying to do it:</p>
  
  <pre><code>[RoutePrefix("api/Image")]
      public class ImageController : ApiController
      {
  
          [HttpPost]
          [Route("Upload")]
          public async Task&lt;IHttpActionResult&gt; UploadAsync()
          {
              var uploadPath = HostingEnvironment.MapPath("/") + "Uploads";
  
              Directory.CreateDirectory(uploadPath);
  
              var provider = new MultipartFormDataStreamProvider(uploadPath);
  
              await Request.Content.ReadAsMultipartAsync(provider);
  
              // Files
              //
              foreach (MultipartFileData file in provider.FileData)
              {
                  Debug.WriteLine(file.Headers.ContentDisposition.FileName);
                  Debug.WriteLine("File path: " + file.LocalFileName);
              }
  
              // Form data
              //
              foreach (var key in provider.FormData.AllKeys)
              {
                  foreach (var val in provider.FormData.GetValues(key))
                  {
                      Debug.WriteLine(string.Format("{0}: {1}", key, val));
                  }
              }
  
              return Ok("Working"); 
          }
      }
  </code></pre>
  
  <p>I'm also adding this for the size of the files</p>
  
  <pre><code>  &lt;system.web&gt;
      &lt;compilation debug="true" targetFramework="4.5.2" /&gt;
      &lt;httpRuntime targetFramework="4.5.2"  maxRequestLength ="100000"/&gt;
    &lt;/system.web&gt;
  </code></pre>
  
  <p>I can see a part of the file uploaded to the upload folder but I keep getting the Client Disconnected problem.. I didn't have this problem up against a PHP script that simply picked up the file and just moved it to a folder of my choice I'm not a PHP developer so I have now chosen something more comfortable for me to build a more advance version however I'm struggling to just receive the file.. </p>
  
  <p>any suggestions to what I'm doing wrong ?</p>
  
  <p>I've tried reverting back to the PHP script that worked on the mac server to see if it was something more fundamental. when I run the PHP script on a Windows server I get the </p>
  
  <blockquote>
    <p>[Tue Apr 11 12:38:05 2017] [IP]:[port number] Invalid request (Unexpected EOF)</p>
  </blockquote>
  
  <p>this did not happen when I was running the PHP script on the mac for testing purposes of the app. So now my question is could it be the same EOF problem I'm having on the Web API. and how do I go about solving a EOF problem ? I do not think I can solve it in windows because windows cannot find the End of the file. ?</p>