There is a pending asynchronous operation, and only one asynchronous operation can be pending concurrently RRS feed

  • Question

  • When running this on my dev machine no issues, works great.  When deployed to my server I always get the error...

    System.IO.IOException: Error reading MIME multipart body part. --->  System.InvalidOperationException: There is a pending asynchronous  operation, and only one asynchronous operation can be pending  concurrently.   at  System.Web.Hosting.IIS7WorkerRequest.BeginRead(Byte[] buffer, Int32  offset, Int32 count, AsyncCallback callback, Object state)

    I am attempting to upload an image.  When I run this on my local machine no errors and the file does get uploaded.

     public async Task<HttpResponseMessage> PostFile(int TaskID)
            // Check if the request contains multipart/form-data. 
            if (!Request.Content.IsMimeMultipartContent())
                throw new HttpResponseException(HttpStatusCode.UnsupportedMediaType);
                StringBuilder sb = new StringBuilder(); // Holds the response body 
                string root = HttpContext.Current.Server.MapPath("~/App_Data");
                var provider = new MultipartFormDataStreamProvider(root);
                //// Read the form data and return an async task. 
                await Request.Content.ReadAsMultipartAsync(provider);
    The error hits the last line of the code that begins with await.

    Friday, December 19, 2014 3:13 PM

All replies