title: How to post file to ASP.NET Web Api 2
body: <p>I'd like to post a file to my webapi. It's not the problem but:</p>
  
  <ol>
  <li>I <strong>don't</strong> want to use javascript</li>
  <li>The file <strong>must</strong> be received and saved <strong>synchronously</strong></li>
  <li><p>I would like my action to look like this:</p>
  
  <pre><code>public void Post(byte[] file)
  {
  
  }
  </code></pre>
  
  <p>or:</p>
  
  <pre><code>public void Post(Stream stream)
  {
  
  }
  </code></pre></li>
  <li><p>I want to post file from code similiar to this (of course, now it doesn't work):</p>
  
  <pre><code>&lt;form id="postFile" enctype="multipart/form-data" method="post"&gt;
  
      &lt;input type="file" name="file" /&gt;
  
      &lt;button value="post" type="submit" form="postFile"  formmethod="post" formaction="&lt;%= Url.RouteUrl("WebApi", new { @httpRoute = "" }) %&gt;" /&gt;
  
  &lt;/form&gt;
  </code></pre></li>
  </ol>
  
  <p>Any suggestions will be appreciated</p>