mvc上传文件超过了最大请求长度

在mvc项目中使用 <form id="Btn_Upload" enctype="multipart/form-data" method="post" style="display:none"><input type="file"  name="file" id="Btn_File" /></form>上传文件时,

出现异常详细信息: System.Web.HttpException: 超过了最大请求长度。

解决办法,在项目web.config文件上添加如下配置

1)在<system.web>下添加最大请求长度

<system.web>
 <!--最大请求长度,单位为KB(千字节),默认为4M,设置为10M,上限为2G,executionTimeout单位秒-->
<httpRuntime maxRequestLength="10240" executionTimeout="60" /> </system.web>

2)在<system.webServer>下添加允许上传文件长度

<system.webServer> 
  <!--允许上传文件长度,单位字节(B),默认为30M,设置为1G,最大为2G -->
    <security>
       <requestFiltering>
         <requestLimits maxAllowedContentLength="1073741824"/>
      </requestFiltering>
    </security>
 </system.webServer>
原文地址:https://www.cnblogs.com/zhusk/p/11491823.html