title: ASP.NET Web API File saved as "BodyPart_3ded2bfb-40be-4183-b789-9301f93e90af"
body: <p>I'm uploading files using the ASP.NET Web API. I've done this before the RC but for some reason the file is being saved as "BodyPart_3ded2bfb-40be-4183-b789-9301f93e90af" instead of the file name. The filename variable below returns this bodypart string too instead of the file name. I can't seem to figure out where I'm going wrong. Any help is appreciated.</p>
  
  <p>Client code:</p>
  
  <pre><code>function upload() {
      $("#divResult").html("Uploading...");
      var formData = new FormData($('form')[0]); 
      $.ajax({
          url: 'api/files/uploadfile?folder=' + $('#ddlFolders').val(),
          type: 'POST',
          success: function (data) {
              $("#divResult").html(data);
          },
          data: formData,
          cache: false,
          contentType: false,
          processData: false
      });
  }; 
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>    public Task&lt;HttpResponseMessage&gt; UploadFile([FromUri]string folder)
      {
          if (!Request.Content.IsMimeMultipartContent())
          {
              throw new HttpResponseException(Request.CreateResponse(HttpStatusCode.UnsupportedMediaType));
          }
  
          // Save file
          MultipartFormDataStreamProvider provider = new MultipartFormDataStreamProvider(HttpContext.Current.Server.MapPath("~/Files"));
          Task&lt;IEnumerable&lt;HttpContent&gt;&gt; task = Request.Content.ReadAsMultipartAsync(provider);
  
          return task.ContinueWith&lt;HttpResponseMessage&gt;(contents =&gt;
          {
              string filename = provider.BodyPartFileNames.First().Value;
              return new HttpResponseMessage()
            {
                Content = new StringContent(string.Format("File saved in {0}.", folder))
            };
  
          }, TaskScheduler.FromCurrentSynchronizationContext());
  </code></pre>
  
  <p>The files are looking like:</p>
  
  <p><img src="https://i.stack.imgur.com/KFy23.png" alt="enter image description here"></p>