.net配置上传文件大小限制

 1、 修改IIS的applicationhost.config,文件位置: %windir%/system32/inetsrv/config/applicationhost.config
       找到<requestFiltering>节点,该节点下默认没有 <requestLimits maxAllowedContentLength="上传大小的值(单位:byte)" /> 元素。
       为这个节点添加如下元素:<requestLimits maxAllowedContentLength="2147483647" /> (上传的大小将改为2GB)


 2、 经过这个设置后,服务器对上传文件的大小限制将变为2147483647bytes了。当然,这个设置是服务器级别的,如果你想在某个站点或 者某个应用上限制大小,也可以通过以相同方式进行设置,只不过这次设置的是站点内的Web.config。
     但是你要进行此项修改,要确保applicationhost.config中对该项修改的权限已经放开。可通过如下设置进行更改:
     若overrideModeDefault的值为Deny,则修改它的值为Allow,如下:
       <sectionGroup name="system.webServer">
          <section name="requestFiltering" overrideModeDefault="Allow" />
       </sectionGroup>
      确认修改过applicationhost.config中上述设置以后,再进行如下设置。
      找到应用的Web.config,把以下内容加在<system.webServer>节点:
     <security>
       <requestFiltering >
         <requestLimits maxAllowedContentLength="2147483647" ></requestLimits>
      </requestFiltering>
     </security>


3、 设置单个请求的最大长度为200MB,修改web.config中  configuration节点下的 system.web节点下的 httpRuntime 节点增加 maxRequestLength="204800" executionTimeout="120"

原文地址:https://www.cnblogs.com/qqxiongmao/p/5842885.html