Skip to content

System.IO.IOException thrown by MultipartReaderStream #3000

@jkotas

Description

@jkotas

From @dvdobrovolskiy on March 25, 2018 0:28

Have this code
FileUploadSample

works perfectly well on 2.0 but is I implement it in 1.0 (version 1.1.7) project throws "'System.IO.IOException' in mscorlib.dll" exception.

Here controller

        [HttpPost]
        [DisableFormValueModelBinding]
        [ValidateAntiForgeryToken]
        public async Task<IActionResult> Upload()
        {
            if (!MultipartRequestHelper.IsMultipartContentType(Request.ContentType))
            {
                return BadRequest($"Expected a multipart request, but got {Request.ContentType}");
            }

            // Used to accumulate all the form url encoded key value pairs in the 
            // request.
            var formAccumulator = new KeyValueAccumulator();
            string targetFilePath = null;

            var boundary = MultipartRequestHelper.GetBoundary(
                MediaTypeHeaderValue.Parse(Request.ContentType),
                _defaultFormOptions.MultipartBoundaryLengthLimit);
            var reader = new MultipartReader(boundary, HttpContext.Request.Body);

            var section = await reader.ReadNextSectionAsync();     //<===Exception here

Sorry if I forgot to set temp path somewhere but I am far before reading data to my stream or temp file

Copied from original issue: dotnet/coreclr#17197

Metadata

Metadata

Assignees

No one assigned

    Labels

    area-networkingIncludes servers, yarp, json patch, bedrock, websockets, http client factory, and http abstractionsfeature-http-abstractions

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions