Unexpected end of stream at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream
<pre><code>System.IO.IOException: Unexpected end of stream.
at Microsoft.AspNetCore.WebUtilities.MultipartReaderStream.&lt;ReadAsync&gt;d__32.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.WebUtilities.StreamHelperExtensions.&lt;DrainAsync&gt;d__2.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.AspNetCore.WebUtilities.MultipartReader.&lt;ReadNextSectionAsync&gt;d__14.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.Runtime.CompilerServices.TaskAwaiter`1.GetResult()
at AspNetCoreFileUpload.Controllers.FileUploadController.&lt;Index&gt;d__0.MoveNext() 
in C:\\GitHub\\StackOverflow\\LargeFileUploadController\\FileUploadController.cs:line 29
</code></pre>

<p>Repro: <a href="https://github.com/bigfont/StackOverflow/tree/master/LargeFileUploadController" rel="noreferrer">https://github.com/bigfont/StackOverflow/tree/master/LargeFileUploadController</a></p>

<p>Form</p>

<pre><code>&lt;form action = ""/FileUpload"" method=""post"" enctype=""multipart/form-data""&gt;
    &lt;label for=""myfile1""&gt;File&lt;/label&gt;
    &lt;input type=""file"" name=""myFile1"" /&gt;
    &lt;label for=""myfile2""&gt;File&lt;/label&gt;
    &lt;input type=""file"" name=""myFile2"" /&gt;
    &lt;input type=""submit"" value=""Send"" /&gt;
&lt;/form&gt;
</code></pre>

<p>Controller </p>

<pre><code>public class FileUploadController : Controller
{
    [HttpPost]
    public async Task&lt;IActionResult&gt; Index()
    {
        var boundary = GetBoundary(Request.ContentType);
        var reader = new MultipartReader(boundary, Request.Body);

        try
        {
            var section = await reader.ReadNextSectionAsync();
        }
        catch (System.Exception ex)
        {
            return new OkObjectResult(new { ex = ex.ToString() });
        }

        return new OkObjectResult(new { message = "Done" });
    }

    private static string GetBoundary(string contentType)
    {
        var elements = contentType.Split(' ');
        var element = elements.Where(entry =&gt; entry.StartsWith("boundary=")).First();
        var boundary = element.Substring("boundary=".Length);
        // Remove quotes
        if (boundary.Length &gt;= 2 &amp;&amp; 
            boundary[0] == '"' &amp;&amp; boundary[boundary.Length - 1] == '"')
        {
            boundary = boundary.Substring(1, boundary.Length - 2);
        }
        return boundary;
    }
}
</code></pre>