NET6 文件上传异常:413

1.Api 增加特性:DisableRequestSizeLimit

2.IIS根目录Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <system.webServer>
      <security>
        <requestFiltering>
          <!-- 设置最大允许的内容长度为 100 MB (单位:字节) -->
          <requestLimits maxAllowedContentLength="104857600" />
        </requestFiltering>
      </security>
    <!-- 其他配置 -->
  </system.webServer>
</configuration>

3.命令修改服务器iis配置

3.1.管理员启动cmd

cd %windir%\system32\inetsrv

3.2.查看指定iis站点文件上传大小:byte

appcmd list config "IIS 站点名称" -section:system.webServer/serverRuntime

3.3.设置新上传大小

appcmd set config "IIS 站点名称" -section:system.webServer/serverRuntime /uploadReadAheadSize:"104857600" /commit:apphost

 

posted @ 2026-04-02 13:55  Robot-Blog  阅读(19)  评论(0)    收藏  举报