简体   繁体   中英

ASP.NET MVC : maximum request length exceeded despite maxRequestLength maxAllowedContentLength set in web.config

I've been trying to upload a file larger than 4mb to an ASP.NET MVC web application (for a long time) and I've looked at so many stack exchange articles so I am aware this is a duplicate, but I've tried everything I'm not making any progress.

I'm running Visual Studio 2019 16.3.9 / IISExpress 10.0 / .NET 4.5.2.

The following code has been added

<location path="UploadedAudio">
  <system.web>
    <httpRuntime executionTimeout="3600" maxRequestLength="1048576" />
  </system.web>
  <system.webServer>
    <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="1073741824" />
      </requestFiltering>
    </security>
  </system.webServer>
</location>

Things I've tried to resolve the issue:

  • adding the above code to all of the below files (individually & all together) -

     ~/View/web.config ~/web.Debug.config ~/web.config
  • I've tried this without <location> .

  • Windows features - Request Filtering on - https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/requestlimits/

  • From what I've read it's means to be in - 'View/web.config'

  • I've read that adding the above code to the following file could work:

     C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\web.config
  • Setting maxRequestLength lower than maxAllowedContentLength

But nothing seems to work for me. Are there any considerations for running in debug mode in Visual Studio that I'm missing?

Any help would or corrections would be greatly appreciated!

I had to copy this - C:\\Windows\\Microsoft.NET\\Framework64\\v4.0.30319\\web.config

edit it with the maxRequestLength and maxAllowedContentLength

then copy the file back into the directory.

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