title: Issues with MultipartFormDataStreamProvider
body: <p>I'm trying to follow <a href="http://www.strathweb.com/2012/04/html5-drag-and-drop-asynchronous-multi-file-upload-with-asp-net-webapi/">this tutorial</a>, and I'm realizing that even if I copy and past his code, I'm getting two compile errors in my ApiController.</p>
  
  <pre><code>IEnumerable&lt;HttpContent&gt; bodyparts = Request.Content.ReadAsMultipartAsync(streamProvider);
  </code></pre>
  
  <p>This tells me that the return of ReadAsMultipartAsync can't be cast to an IEnumerable of HttpContent.</p>
  
  <pre><code>IDictionary&lt;string, string&gt; bodypartFiles = streamProvider.BodyPartFileNames;
  </code></pre>
  
  <p>And this is telling me that BodyPartFileNames doesn't exist in streamProvider, which seems contrary to the tutorial as well as several other blog posts and StackOverflow questions I've seen.</p>
  
  <p>Anyone have any idea what the deal is?</p>
  
  <p>Full file:</p>
  
  <pre><code>using AsyncFileUpload.Models;
  using System;
  using System.Collections.Generic;
  using System.IO;
  using System.Linq;
  using System.Net;
  using System.Net.Http;
  using System.Threading;
  using System.Threading.Tasks;
  using System.Web.Http;
  
  
  namespace AsyncFileUpload.Controllers
  {
      public class UploadingController : ApiController
      {
          private const string PATH = "C:\\_projects\\learning";
  
          [HttpPost]
          public async Task&lt;IList&lt;FileDesc&gt;&gt; Post()
          {
              List&lt;FileDesc&gt; result = new List&lt;FileDesc&gt;();
              if (Request.Content.IsMimeMultipartContent())
              {
                  try
                  {
                      if (!Directory.Exists(PATH))
                      {
                          Directory.CreateDirectory(PATH);
                      }
  
                      MultipartFormDataStreamProvider streamProvider =
                          new MultipartFormDataStreamProvider(PATH);
  
                      IEnumerable&lt;HttpContent&gt; bodyparts = Request.Content.ReadAsMultipartAsync(streamProvider);
                      IDictionary&lt;string, string&gt; bodypartFiles = streamProvider.BodyPartFileNames;
                      IList&lt;string&gt; newFiles = new List&lt;string&gt;();
  
                      foreach (var item in bodypartFiles)
                      {
                          var newName = string.Empty;
                          var file = new FileInfo(item.Value);
  
                          if (item.Key.Contains("\""))
                          {
                              newName = Path.Combine(file.Directory.ToString(),
                                  item.Key.Substring(1, item.Key.Length - 2));
                          }
                          else
                          {
                              newName = Path.Combine(file.Directory.ToString(), item.Key);
                          }
  
                          File.Move(file.FullName, newName);
                          newFiles.Add(newName);
                      }
  
                      var uploadedFiles = newFiles.Select(i =&gt;
                          {
                              var fi = new FileInfo(i);
                              return new FileDesc(fi.Name, fi.FullName, fi.Length);
                          }).ToList();
  
                      result.AddRange(uploadedFiles);
                  }
                  catch (Exception e)
                  {
                      // NOOP
                  }
              }
              return result;
          }
      }
  }
  </code></pre>