title: Asp.net Web Api Streaming
body: <p>I have been trying to stream a file to my web service. In my Controller(ApiController) I have a Post function as follows: </p>
  
  <pre><code>public void Post(Stream stream)
  {
      if (stream != null &amp;&amp; stream.Length &gt; 0)
      {
          _websitesContext.Files.Add(new DbFile() { Filename = Guid.NewGuid().ToString(), FileBytes= ToBytes(stream) });
          _websitesContext.SaveChanges();
      }
  }
  </code></pre>
  
  <p>I have been trying to stream a file with my web client by doing the following: </p>
  
  <pre><code>public void UploadFileStream(HttpPostedFileBase file)
  {
      WebClient myWebClient = new WebClient();
      Stream postStream = myWebClient.OpenWrite(GetFileServiceUrl(), "POST");
      var buffer = ToBytes(file.InputStream);
      postStream.Write(buffer, 0,buffer.Length);
      postStream.Close();
  }
  </code></pre>
  
  <p>Now when i debug my web service, it gets into the Post function, but stream is always null. Was wondering if anyone may have an idea why this is happening? </p>