Note that there are some explanatory texts on larger screens.

plurals
  1. PORequest.Content.ReadAsMultipartAsync never returns
    primarykey
    data
    text
    <p>I have an API for a system written using the ASP.NET Web Api and am trying to extend it to allow images to be uploaded. I have done some googling and found how the recommended way to accept files using MultpartMemoryStreamProvider and some async methods but my await on the ReadAsMultipartAsync never returns.</p> <p>Here is the code:</p> <pre><code>[HttpPost] public async Task&lt;HttpResponseMessage&gt; LowResImage(int id) { if (!Request.Content.IsMimeMultipartContent()) { throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType); } var provider = new MultipartMemoryStreamProvider(); try { await Request.Content.ReadAsMultipartAsync(provider); foreach (var item in provider.Contents) { if (item.Headers.ContentDisposition.FileName != null) { } } return Request.CreateResponse(HttpStatusCode.OK); } catch (System.Exception e) { return Request.CreateErrorResponse(HttpStatusCode.InternalServerError, e); } } </code></pre> <p>I can step through all the way to:</p> <pre><code>await Request.Content.ReadAsMultipartAsync(provider); </code></pre> <p>at which point it will never complete.</p> <p>What is the reason why my await never returns?</p> <h1>Update</h1> <p>I am attempting to POST to this action using curl, the command is as follows:</p> <pre><code>C:\cURL&gt;curl -i -F filedata=@C:\LowResExample.jpg http://localhost:8000/Api/Photos/89/LowResImage </code></pre> <p>I have also tried using the following html to POST to the action as well and the same thing happens:</p> <pre><code>&lt;form method="POST" action="http://localhost:8000/Api/Photos/89/LowResImage" enctype="multipart/form-data"&gt; &lt;input type="file" name="fileupload"/&gt; &lt;input type="submit" name="submit"/&gt; &lt;/form&gt; </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload