0

I'm getting the http response code 413 when I try to upload a large file (>30mb) with an Asp.Net core mvc controller deployen on a windows server 2016.

The web service is running on IIS ("In process").

The controller looks like:

[Route("api/[controller]")]
[ApiController]
public class FileController : ControllerBase
{
    [HttpPost]
    [DisableRequestSizeLimit]
    [DisableFormValueModelBinding]
    public async Task<ActionResult<Guid>> Upload(IFormFile file)
    {
       [...] 
    }
}

I'm using this setting in the startup class:

public void ConfigureServices(IServiceCollection services)
{
    [...]
    services.Configure<FormOptions>(x =>
    {
       x.MultipartBodyLengthLimit = long.MaxValue;
    });
}

And I have those settings in my app web.Config to prevent request size limit:

<system.webServer>
    <security>
        <requestFiltering>
            <requestLimits maxAllowedContentLength="1073741824" />
        </requestFiltering>
    </security>
    <serverRuntime maxRequestEntityAllowed="4294967295" uploadReadAheadSize="2147483647" />
</system.webServer>

This is working perfercly when I run it locally on my machine (windows 10 + IIS)

But as soon I publish the solution on the windows server 2016 machine I get the 413 error when I try to uplad a file >30mb.

Note: the applicationHost.Config on the server is allowing the override of the sections:

system.webServer/security/requestFiltering/requestLimits

system.webServer/serverRuntime

Jows
  • 461
  • 4
  • 9

1 Answers1

1

I realized the .net core hosting bunble version was not the same on my machine 3.1.3 than the server machine 3.1.2.

After updating it on the server with the latest available version, the upload of large files started to work without generating 413 error.

Jows
  • 461
  • 4
  • 9