HttpRequest 获取上传文件,超过了最大限制

解决办法

1.在webconfig文件中添加

  <system.web>
<httpRuntime maxRequestLength="1024000" executionTimeout="3600" />
  </system.web>

2.修改maxRequestLength:在web.config中我们修改<system.web></system.web>中的maxRequestLength,表示最大请求长度,单位是kb,默认4M,修改为1G

3.在<system.webServer>添加

<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1024000000"></requestLimits>
</requestFiltering>
</security>

4.修改maxAllowedContentLength:在web.config中我们修改<system.webServer></system.webServer>中的maxAllowedContentLength,表示附件大小上限,单位是字节,默认约30M,修改为1G

注意:maxRequestLength与maxAllowedContentLength的区别

a、前者表示请求长度,后者表示上传文件的大小;

b、前者单位kb,后者单位字节;

c、前者默认值4M,后者默认值30000000B,约30M;

d、两者的最大值都为2G

参考网址:https://www.jb51.net/article/88698.htm

原文地址:https://www.cnblogs.com/wxxf/p/11594848.html