首页 > Web开发 > 详细

ASP.NET中maxRequestLength和maxAllowedContentLength的区别;上传大文件设置IIS7文件上传的最大大小

时间:2020-07-29 16:09:14      阅读:89      评论:0      收藏:0      [点我收藏+]

  maxRequestLength表示ASP支持的最大请求大小,而maxAllowedContentLength指定IIS支持的请求中内容的最大长度。因此,要上传大文件,我们需要同时设置这两个参数:较小的那个“优先”,即最终支持上传的文件的大小根据maxRequestLength和maxAllowedContentLength中的较小值而定。
  如果文件长度小于maxAllowedContentLength但大于maxRequestLength,用户将获得标准(ASPX)错误页面。相反,用户会得到IIS错误页面。

 

HTTP Error 404.13 - Not Found
The request filtering module is configured to deny a request that exceeds the request content length.

需要在web.config中配置如下:

 <system.web>

  <httpRuntime requestValidationMode="2.0" maxRequestLength="3072" ></httpRuntime>

  <!--单位:KB 3072=3MB   默认是4MB,最大支持2GB-->

 </system.web>

<system.webServer>

 <security>
      <requestFiltering>
        <requestLimits maxAllowedContentLength="2147483648" />
        <!--单位:字节B  2147483648=2 GB 默认是4MB,最大支持2GB-->
      </requestFiltering>
    </security>

</system.webServer>

最后,需要注意的是,maxRequestLength的单位是KB,而maxAllowedContentLength的单位是字节,既然是请求,那么指的不仅仅是上传文件,只要是用户发送的请求,都可以通过上面的配置限制,比如Ajax请求服务器接口,参数内容超过了设置的最大长度就会请求失败!

ASP.NET中maxRequestLength和maxAllowedContentLength的区别;上传大文件设置IIS7文件上传的最大大小

原文:https://www.cnblogs.com/Aiti59/p/13397521.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!