For my Core 2.2 MVC project, combining the [RequestSizeLimit(long.MaxValue)] attribute and the web.config above did not work. The web.config alone worked - Just don't use the attribute. The application crashed and closed the browser unexpectedly. Also, because my max request size is 200Mb, if it's possible to generate a 404.13 (req. too large) result, then your normal status code handling will not work for the 404.13 (see Startup.cs, Configure(), the
app.UseStatusCodePagesWithReExecute("/Error/Error", "?statusCode={0}");
line). The status code pages handling works for other codes though. I had to insert custom error status handling into the web.config file to handle 404.13 with a graceful user friendly view. Note that the 'remove' for the 404.13 also appears to remove status code 404 ... and then your Error controller method will not handle a 404. There are two custom error handlers in the web.config below - One for the 404.13 and one for the 404 in order to fix this. Hope this helps someone:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<security>
<requestFiltering>
<!-- This will handle requests up to 201Mb -->
<requestLimits maxAllowedContentLength="210763776" />
</requestFiltering>
</security>
<httpErrors errorMode="Custom" existingResponse="Replace">
<remove statusCode="404" subStatusCode="13" />
<remove statusCode="404" />
<error statusCode="404"
subStatusCode="13"
prefixLanguageFilePath=""
path="/Error/UploadTooLarge"
responseMode="Redirect" />
<error statusCode="404"
prefixLanguageFilePath=""
path="/Error/PageNotFound"
responseMode="Redirect" />
</httpErrors>
</system.webServer>
</configuration>
The end result is that all normal status codes are handled by Error/Error, and the 404.13 and 404 status codes have custom handling ... and nice views all around!