c# 上传文件太大报错,处置惩罚为可上传20M一下文件

[复制链接]
发表于 2025-10-1 21:16:00 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
 <system.webServer>

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

<system.web>
    <compilation debug="true" targetFramework="4.5" />
    <httpRuntime targetFramework="4.5" maxRequestLength="20480" executionTimeout="3600" />  </system.web>


  • 在<httpRuntime>标签中添加了以部属性:


  • maxRequestLength="20480" - 这设置了最大哀求长度为20MB(20480KB)


  • executionTimeout="3600" - 这增长了哀求超时时间到3600秒(1小时),确保有充足的时间处置惩罚大文件上传
  • 2在<system.webServer>部分添加了<security>设置:
  • <requestLimits maxAllowedContentLength="20971520" /> - 这设置了IIS的最大内容长度为20MB(20971520字节)
回复

使用道具 举报

登录后关闭弹窗

登录参与点评抽奖  加入IT实名职场社区
去登录
快速回复 返回顶部 返回列表