0
votes

I'm hitting a problem with multipart/form-data POST uploads on IIS. My client is an Angular SPA and my backend is on .Net Core 2.1 (I know it's old).

The backend project is published as Self-Contained win-x64. I'm not sure how it's configured exactly on IIS / Kestrel but the IIS App runs under a specific Application Pool (No managed Code / Integrated). My web.config looks like this:

<configuration>
    <location path="." inheritInChildApplications="false">
        <system.web>
            <httpRuntime maxRequestLength="1048576" />
        </system.web>
        <system.webServer>
            <security>
                <requestFiltering>
                    <requestLimits maxAllowedContentLength="1073741824" />
                </requestFiltering>
            </security>
            <handlers>
                <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModule" resourceType="Unspecified" />
            </handlers>
            <aspNetCore processPath=".\my.app.exe" stdoutLogEnabled="false" stdoutLogFile=".\log\path" />
        </system.webServer>
    </location>
</configuration>

In my development environment instead I'm using IIS Expres.

Now I added a multipart/form-data upload, sending form data together with a blob/image. This worked out of the box in development settings. However when I publish to staging environment with real IIS and the above web.config, I always get 413 Request entity too large.

My controller looks like this:

[HttpPost]
[DisableRequestSizeLimit]
[RequestFormLimits(MultipartBodyLengthLimit = int.MaxValue, ValueLengthLimit = int.MaxValue)]
[RequestSizeLimit(int.MaxValue)]
[Route("my/route")]
public ActionResult MyHandler()

I also added limits for Kestrel in Program.cs:

.UseKestrel(options =>
    {
        options.Limits.MaxRequestBodySize = 104857600; // 100MB
    }
)

And to make the weirdness complete the 413 in staging environment only happens in Firefox. I have no idea what else I can do. I also cleared cache in firefox.

1
Here is a link about 413 in firefox.Maybe you can try to refer to it.Yiyi You
Hi @YiyiYou, I'm not using Firefox Android but thanks for the link. I found the solution in the meantime and I'll add it soon.GeofoxCoding

1 Answers

0
votes

After longer search I finally found the necessary setting in IIS to make this work in Firefox. And it has indeed be mentioned in a few sources as the 'last option'. For me it was necessary in this case.

In 'IIS Manager' I selected the backend application and opened 'Configuration Editor' system.webServer/serverRuntime -> uploadReadAheadSize=2147483647

That maked it work.