413 请求实体太大 - 文件上传 ASP.NET MVC

时间:2021-03-21 00:47:41

标签: asp.net asp.net-mvc iis web-config

尝试使用 asp.net mvc 上传大约 500 MB 的大文件。

我的 web.config 如下所示,但我仍然在生产服务器上收到错误,但它在我的本地 IIS(不是 IIS Express)上运行:

 <httpRuntime targetFramework="4.5" maxRequestLength="1048576" />

....
     <system.webServer>
      <security>
          <requestFiltering>
                  <requestLimits maxAllowedContentLength="1048576000" />

          </requestFiltering>
      </security>
  </system.webServer>

1 个答案:

答案 0 :(得分:1)

解决方案:

最快的解决方案是增加上传大小限制。 IIS 使用 applicationHost.config 和 web.config 文件中的 uploadReadAheadSize 参数来控制此限制。

更改此参数值的步骤:

  1. 打开 IIS 管理器

  2. 选择网站

  3. 双击“配置编辑器”

  4. 选择 system.webServer 然后选择 serverRuntime

  5. 修改uploadReadAheadSize值

  6. 点击“应用”

enter image description here