title: Post Stream in ASP.NET Core Web Api
body: <p>Hello lovely people of Stack Overflow.
  Since yesterday I have a problem and I have been browsing SO since then.
  I have a UWP Client and ASP.NET Core Web Api. I just want to send a stream to my web api but indeed this occurred to be harder task than i thought.</p>
  
  <p>I have a class which I have only one property. The <code>Stream</code> property as you can see below:</p>
  
  <pre><code>public class UploadData
  {
      public Stream InputData { get; set; }
  }
  </code></pre>
  
  <p>Then Here is my code from my Web Api:</p>
  
  <pre><code>// POST api/values
  [HttpPost]
  public string Post(UploadData data)
  {
      return "test";
  }
  </code></pre>
  
  <p>I have tried to read the stream From body but the result is same.
  I can hit the post method <code>UploadData</code> is not null but my <code>InputData</code> is always <code>null</code>.</p>
  
  <p>Here is my UWP's code for post request.</p>
  
  <pre><code>private async void PostStreamButton_OnClick(object sender, RoutedEventArgs e)
  {
      using (var client = new HttpClient())
      {
          var dummyBuffer = new UnicodeEncoding().GetBytes("this is dummy stream");
          var dummyStream = new MemoryStream(dummyBuffer).AsRandomAccessStream().AsStream();
  
          var requestContent = new MultipartFormDataContent();
          var inputData = new StreamContent(dummyStream);
          inputData.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");
          requestContent.Headers.ContentType = new MediaTypeHeaderValue("application/json");
  
          requestContent.Add(inputData, "inputData");
  
          HttpResponseMessage response = client.PostAsync("url", inputData).Result;
      }
  }
  </code></pre>
  
  <p>I have tried various of content types which none of them seems to work and I have no idea why. I would really appreciate all the help.</p>