首页 技术 正文
技术 2022年11月14日
0 收藏 968 点赞 4,757 浏览 1931 个字

首先,最容易找到的是web.config下面配置:

    <!--maxRequestLength=50MB-->
<httpRuntime targetFramework="4.5.2" maxRequestLength="51200"/>

这么设置会将请求的尺寸从默认4MB(4096KB)提升到50MB(51200KB)。

但是,如果只是这么设置的话,你会发现你的最大上传尺寸会停止在28.6MB,更大的文件上传,将返回404.13,表示内容长度过大。

原因在于IIS的默认设置,限定了maxAllowedContentLength的值。

<element name="requestLimits"><attribute name="maxAllowedContentLength" type="uint" defaultValue="30000000" />

该值在IIS_Schema.xml中设置。(将影响整个计算机)

IISExpress:IISExpress运行路径下,C:\Program Files (x86)\IIS Express\config\schema\IIS_schema.xml
IIS7、8:C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml

如果修改了这个值没有生效,两种可能,一种是当前运行的IISExpress/IIS没有关闭/重启。一种是web.config中有额外的配置(如下文所述)。

然而为了避免总是去修改全局的值,影响到同一台服务器上的其他web站点,我们还可以在web.config中进行配置。

  <system.webServer>
<!--
IISExpress:C:\Users\UserName\Documents\IISExpress\config\applicationHost.config
IIS7、8:C:\Windows\System32\inetsrv\config\applicationHost.config
<section name="requestFiltering" overrideModeDefault="Allow" />
overrideModeDefault值设置成Allow的时候,本配置节才会生效。 也可以在IIS_Schema.xml中设置。(将影响整个计算机)
IISExpress:IISExpress运行路径下,C:\Program Files (x86)\IIS Express\config\schema\IIS_schema.xml
IIS7、8:C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml
修改defaultValue="30000000"(28.6MB)为需要的值。
<element name="requestLimits"><attribute name="maxAllowedContentLength" type="uint" defaultValue="30000000" />
-->
<security>
<requestFiltering>
<!--maxAllowedContentLength=100MB-->
<requestLimits maxAllowedContentLength="104857600"></requestLimits>
</requestFiltering>
</security>

为了使该内容生效,需要配置“允许继承”,在applicationHost.config中搜索<section name=”requestFiltering” overrideModeDefault=”Allow” />中的关键字,确保这个值为Allow即可。

IISExpress:C:\Users\UserName\Documents\IISExpress\config\applicationHost.config
IIS7、8:C:\Windows\System32\inetsrv\config\applicationHost.config

参考资料:

http://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits

http://www.cnblogs.com/henryhappier/archive/2010/09/20/1832098.html

https://msdn.microsoft.com/en-us/library/ms689462(v=vs.90).aspx

相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:9,088
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,564
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,413
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,186
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,822
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,905