0
点赞
收藏
分享

微信扫一扫

Windows中IIS7设置上传文件大小限制

IIS 7 默认文件上传大小时限制30M。

要突破这个限制:

1.  修改IIS的applicationhost.config

Windows中IIS7设置上传文件大小限制_上传

打开 %windir%\system32\inetsrv\config\applicationhost.config

找到:<requestFiltering>节点,这个节点默认没有 <requestLimits maxAllowedCnotallow="上传大小的值(单位:byte)" /> 元素,IIS 7和IIS 7.5上测试过  最大值只能是<requestLimits maxAllowedCnotallow="4294967295" />  <4GB,

为这个节点新增如下事例元素:<requestLimits maxAllowedCnotallow="2147483647" /> ,上传的大小将改为2G。

Windows中IIS7设置上传文件大小限制_上传_02

注意: %windir%\system32\inetsrv\config\applicationhost.config 文件一定不要用其他机器的文件替换,否则IIS将无法启动。备份的config文件也不要放在同一目录下。

此文件记录了,当前IIS中所有Site , App pool的信息,还有一些与机器相关的配置。

2 修改web.config

<system.web>

<httpRuntime executinotallow="36000" maxRequestLength="2097151"/>   <!--maxRequestLength:上传的大小,单位K   ,executionTimeout:设置超时时间,单位:秒。(默认是90秒) -->

</system.web>

注意:这个maxRequestLength最大值只能是2097151K,设置大于这个值将会出现如下错误:

Configuration Error

Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

Parser Error Message: The value for the property 'maxRequestLength' is not valid. The error is: The value must be inside the range 0-2097151.

Source Error:

Line 101:    <httpHandlers />

Line 102:    <customErrors mode="RemoteOnly" />

Line 103:    <httpRuntime executinotallow="36000" maxRequestLength="4194304" />

Line 104:    <authentication mode="Windows" />

Line 105:    <identity impersnotallow="true" />

3.  web.config下如果有如下节点(此节点是为IIS 7设计的) ,则修改

<requestLimits maxAllowedCnotallow="2147483647" /> 单位与applicationhost.config中的<requestLimits maxAllowedCnotallow="2147483647" />一致,它的最大值也只能为4294967295

<system.webServer>

<security>

<requestFiltering>

<requestLimits maxAllowedCnotallow="2147483647" />

</requestFiltering>

</security>

</system.webServer>

举报

相关推荐

0 条评论