简体   繁体   中英

RequestSizeLimit(100_000_000) not working on IIS

I have a rest API using .net 5.0. I want to use [RequestSizeLimit(100_000_000)] in just one endpoint. When using Kestrel it works, but I want to use it in IIS. I'm missing something? Important: My project has no web.config : None of the solutions showed here: Increase upload file size in Asp.Net core solved my problem.

The RequestSizeLimit attribute allows you to define the maximum request size within your code but it is still limited by maximum request size supported by the server itself, so you can try to set the request size through the maxAllowedContentLength property in iis.

You can try to create a web.config file with the following content:

<system.webServer>
  <security>
    <requestFiltering>
      <!-- This will handle requests up to 50MB -->
      <requestLimits maxAllowedContentLength="52428800" />
    </requestFiltering>
   </security>
</system.webServer>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM