前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >设置IIS7文件上传的最大大小

设置IIS7文件上传的最大大小

作者头像
孤鸿
发布2022-09-23 16:53:47
1K0
发布2022-09-23 16:53:47
举报
文章被收录于专栏:孤鸿孤鸿

设置IIS7文件上传的最大大小 maxAllowedContentLength,maxRequestLength

PS:IIS7.5只能上传2M的数据,超过2M,程序会出现错误。

解决方案:

  • IIS修改方案:
  • 修改IIS的 applicationhost.config 打开 %windir%\system32\inetsrv\config\applicationhost.config 找到: 节点, 这个节点默认没有 元素,IIS 7和IIS 7.5上测试过 最大值只能是 <4GB, 为这个节点新增如下事例元素: ,上传的大小将改为2G

注意:%windir%\system32\inetsrv\config\applicationhost.config 文件一定不要用其他机器的文件替换,否则IIS将无法启动 此文件记录了,当前IIS中所有Site , App pool的信息,还有一些与机器相关的配置。

  • 修改web.config
代码语言:javascript
复制
<system.web>
<httpRuntime executionTimeout="36000" maxRequestLength="2097151"/>

system.web>

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

代码语言:javascript
复制
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:
C:\Windows\System32\inetsrv>appcmd set config "Default Web Site/owa" -section:re
questFiltering -requestLimits.maxAllowedContentLength:1024000
  • web.config下如果有如下节点(此节点是为IIS 7设计的) ,则修改 14484320.06614
  • 单位与applicationhost.config中的 一致,它的最大值也只能为4294967295
代码语言:javascript
复制
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2147483647"/>
requestFiltering>
security>
system.webServer>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档