ASP.NET MVC:尽管在web.config中设置了maxRequestLength maxAllowedContentLength,但超出了最大请求长度

问题描述 投票:0回答:1

很长时间以来,我一直试图将大于4mb的文件上传到ASP.NET MVC Web应用程序,并且我看了很多堆栈交换文章,所以我知道这是重复的,但是我已经尝试了所有我没有取得任何进展的东西。

我正在运行Visual Studio 2019 16.3.9 / IISExpress 10.0 / .NET 4.5.2。

已添加以下代码

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

我已尝试解决此问题的方法:

  • 将上面的代码添加到下面的所有文件中(单独和一起)-

    ~/View/web.config
    ~/web.Debug.config
    ~/web.config
    
  • 我已经在没有<location>的情况下尝试过此操作。

  • Windows功能-请求筛选-https://docs.microsoft.com/en-us/iis/configuration/system.webserver/security/requestfiltering/requestlimits/

  • 据我所读,这意味着进入-'View / web.config'

  • 我已经读过将上面的代码添加到以下文件中可以起作用:

    C:\Windows\Microsoft.NET\Framework64\v4.0.30319\web.config
    
  • maxRequestLength设置为低于maxAllowedContentLength

但是似乎没有什么对我有用。我缺少在Visual Studio中以调试模式运行的任何注意事项吗?

任何帮助或改正将不胜感激!

c# asp.net-mvc file-upload content-length maxrequestlength
1个回答
0
投票

我必须复制此-C:\Windows\Microsoft.NET\Framework64\v4.0.30319\web.config

maxRequestLengthmaxAllowedContentLength编辑

然后将文件复制回目录。

© www.soinside.com 2019 - 2024. All rights reserved.