question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Warning when increasing IHttpMaxRequestBodySizeFeature.MaxRequestBodySize despite all IIS limits increased

See original GitHub issue

I have an ASP.NET Core 3.1 web API running on IIS on-prem (IIS 10 on Windows Server 2016). In an operation, I set IHttpMaxRequestBodySizeFeature.MaxRequestBodySize to 262144000. I have used the IIS Configuration Editor to

  • modify ApplicationHost.config for my site by setting system.webServer/security/requestFiltering/requestLimits/maxAllowedContentLength to 4294967295 enter image description here
  • modify ApplicationHost.config for my site by setting system.webServer/serverRuntime/maxRequestEntityAllowed to 4294967295 enter image description here
  • modify Root Web.config for my site by setting system.web/httpRuntime/maxRequestLength to 2147483647 enter image description here

Those are the values I also see when I choose Web.config in the IIS Configuration Editor.

The site is behind another IIS site acting as a reverse proxy. I have made the same changes there.

I am able to upload files larger than the default ~30MB limit, but I consistently get the following warning whenever I set IHttpMaxRequestBodySizeFeature.MaxRequestBodySize:

Increasing the MaxRequestBodySize conflicts with the max value for IIS limit maxAllowedContentLength. HTTP requests that have a content-length greater than maxAllowedContentLength will still be rejected by IIS. You can disable the limit by either removing or setting the maxAllowedContentLength value to a higher limit.

I have even looked at the ASP.NET source code to verify that the warning only prints if you’re trying to set the limit higher than the IIS settings:

https://github.com/dotnet/aspnetcore/blob/214df1c8ef0cce27b04fcc43d7df48b29964dee1/src/Servers/IIS/IIS/src/Core/IISHttpServer.cs#L85-L88

https://github.com/dotnet/aspnetcore/blob/df712cc4a97d0bc8d573979008a5a2cc381f8117/src/Servers/IIS/IIS/src/Core/IISHttpContext.FeatureCollection.cs#L370-L373

Am I doing anything wrong, or is this a bug in ASP.NET Core?

Please let me know if I can provide more information.

If it’s relevant, I am publishing to IIS using Azure Pipelines. My repo does not contain a web.config, but for good measure I tried with the following web.config without luck:

<configuration>
  <system.web>
    <httpRuntime maxRequestLength="2147483647" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="4294967295" />
      </requestFiltering>
    </security>
  </system.webServer>
</configuration>

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (11 by maintainers)

github_iconTop GitHub Comments

github_iconTop Results From Across the Web

How to use MaxRequestBodySize in ASP.NET Core on IIS ...
Increasing the MaxRequestBodySize conflicts with the max value for IIS limit maxAllowedContentLength. HTTP requests that have a content-length ...
Read more >
ERROR :Increasing the MaxRequestBodySize conflicts ...
Increasing the MaxRequestBodySize conflicts with the max value for IIS limit maxAllowedContentLength. HTTP requests that have a content ...
Read more >
Configure options for the ASP.NET Core Kestrel web server
MaxRequestBodySize gets or sets the maximum allowed size of any request body in bytes. The recommended approach to override the limit in an...
Read more >
HTTP.sys web server implementation in ASP.NET Core
An IsReadOnly property can be used to indicate if the MaxRequestBodySize property is in a read-only state, meaning it's too late to configure ......
Read more >
Increase ASP.NET File Upload Limits
If an MVC action is not handling the request, the limit can still be modified on a per request basis using the IHttpMaxRequestBodySizeFeature...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found