0

I'm having an issue when posting a file to my web server. I get this exception:

Exception raised during upload handling.
IOException: Error reading MIME multipart body part.

StackTrace:

at System.Net.Http.HttpContentMultipartExtensions. <ReadAsMultipartAsync>d__9`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
at Server.Controllers.DataController.d__5.MoveNext()

[InvalidOperationException] Unable to read the entity body in bufferless mode. The request stream has already been buffered.

StackTrace:

at System.Web.Http.WebHost.HttpControllerHandler.<>c__DisplayClass18_0.b__1()
at System.Web.Http.WebHost.HttpControllerHandler.LazyStreamContent.get_StreamContent()
at System.Web.Http.WebHost.HttpControllerHandler.LazyStreamContent.CreateContentReadStreamAsync()
at System.Net.Http.HttpContent.ReadAsStreamAsync()
at System.Net.Http.HttpContentMultipartExtensions.d__9`1.MoveNext()

The odd thing is that the server has been installed on many machines but this error only occurs on one server. The other odd thing is that when uploading the file via the website the file uploads fine. But when trying to upload the file using a application that sends the request to the same server endpoint, it gets this error.

The same file has been used on multiple servers without issue. The same application has uploaded files to other servers without issue.

And yes I have read the multiple other posts with the similar issue (e.g. WebAPI error reading MIME multipart body part ) but I still haven't found a solution. The maxRequestLength and maxAllowedContentLength have been set in the web.config.

Is there an IIS setting I'm missing that should be checked that maybe different on that server? What other solutions can I try?

Not sure what other info is needed. Thank you in advance

11
  • I suspect this has to do with file extensions and applications that are used with the extensions. Each section of the multipart contains a file type (see learn.microsoft.com/en-us/previous-versions/office/developer/…. The problem may be an application is not installed in the server. Commented Feb 20 at 17:00
  • @jdweng I think I understand that but that wouldnt explain why the same file uploads fine when I upload it via the website. The error only occurs when using a console command line client to upload the file to the same server endpoint the website uses Commented Feb 20 at 21:15
  • It could be the content length in the http header. Try uploading with Postman and then check in the control panel Raw Http. Compare the content length in Postman against what you are using in c#. Commented Feb 20 at 22:21
  • you could try other client like postman or something else to test the result s that we can chek if the issue is with the command line client or in the iis configuration. and use the fiddler tool to capture both the request and compare that request and see what is missing in the console client. Have you tried uploading the small file using command line client what was the result? Commented Feb 21 at 9:25
  • @jdweng Thats a good shout. Will have a look at that today. But that wouldnt explain why the command line client works fine on other servers but fails on this one no? Commented Feb 21 at 9:25

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.