IIS WebApi: 文件上传,大小限制,提示413 (Request Entity Too Large)

IIS WebApi: 文件上传,大小限制,提示413 (Request Entity Too Large)

一:在web.config上配置,按照以下格式,将下列标红加粗的地方,按照对应位置复制到web.config中,即可解决。
注:这两个标红处均要复制,配置!!!

httpRuntime 中 maxRequestLength就是设置你上传文件的大小限制;
requestLimits 中 maxAllowedContentLength就是设置你上传文件的大小限制;

<configuration>
  <system.web>
    <compilation targetFramework="4.6.1" />
    <httpRuntime executionTimeout="600" maxRequestLength="419430400" targetFramework="4.6.1" />
  </system.web>
  <system.webServer>
    <security>
        <requestFiltering>
           <requestLimits maxAllowedContentLength="419430400" />
        </requestFiltering>
    </security>
  </system.webServer>
</configuration>

二、IIS中配置

① 打开IIS,找到文件上传的项目,选中->功能试图->配置编辑器(如下图)

② 修改两处(httpRuntime、requestLimits )