0

There is a strange behavior, user is unable to upload a file in web application getting below

'Error reading MIME multipart body part. System.IO.IOException: Error reading MIME multipart body part. ---> System.Web.HttpException: The client disconnected.'

but the same file I am able to upload without any errors.

We tried below options by going through the articles and similar error posts but no luck.

  1. I tried switching out the Task.Factory code:

var task = Task.Factory .StartNew(() => parts = Request.Content.ReadAsMultipartAsync().Result.Contents, CancellationToken.None, TaskCreationOptions.LongRunning, // guarantees separate thread TaskScheduler.Default);

with below

var task = Task.Run(async () => await Request.Content.ReadAsMultipartAsync()); parts = task.Result.Contents;

  1. Increased max request limits in web.config like maxRequestLength="2147483647", maxAllowedContentLength="157286400".

I see errors like below in logs

Error reading MIME multipart body part. System.IO.IOException: Error reading MIME multipart body part. ---> System.Web.HttpException: The client disconnected. at System.Web.Hosting.IIS7WorkerRequest.EndRead(IAsyncResult asyncResult) at System.Web.HttpBufferlessInputStream.EndRead(IAsyncResult asyncResult) at System.Threading.Tasks.TaskFactory1.FromAsyncTrimPromise1.Complete(TInstance thisRef, Func`3 endMethod, IAsyncResult asyncResult, Boolean requiresSynchronization)

I am unable to reproduce this error in any of my environments, not sure what is causing in user environment. Any suggestions?

0 Answers0