学无先后,达者为师

网站首页 编程语言 正文

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

作者:一叶飘零晋 更新时间: 2024-01-05 编程语言

问题: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 )

在这里插入图片描述
在这里插入图片描述
以上就可以解决文件过大无法上传这个问题。

原文链接:https://blog.csdn.net/ChenJin_2/article/details/131677504

  • 上一篇:没有了
  • 下一篇:没有了
栏目分类
最近更新