I recently was attempting to upload multipart/form-data using Flurl and ASPNET Core server was throwing this exception: "System.IO.IOException: Unexpected end of Stream, the content may have already been read by another component.".
The root cause of this error is that the boundary value was wrapped in double quotes in the media type header but was not wrapped in quotes in the request body. The solution was just to trim the double quotes from the boundary value.
Here's the content-type header value from the http request. Notice how the GUID is wrapped in double quotes.
Here's the gist of the request body (binary data omitted). Notice how the same GUIDs lack the double quotes.
I was using
Microsoft.AspNetCore.WebUtilities.MultipartReader to read the http request body. Like so:
The exception was being thrown on this line directly below:
The solution was to trim the double quotes from the boundary: