• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

ASP.Net文件上传大小限制

原作者: [db:作者] 来自: [db:来源] 收藏 邀请
IIS 7 默认文件上传大小时30M
要突破这个限制:

1. 修改IIS的applicationhost.config
    打开 %windir%\system32\inetsrv\config\applicationhost.config 
     找到: <requestFiltering>节点,
  这个节点默认没有 <requestLimitsmaxAllowedContentLength="上传大小的值(单位:byte)" /> 元素,IIS 7和IIS 7.5上测试过  最大值只能是<requestLimits maxAllowedContentLength="4294967295" />  <4GB,
     为这个节点新增如下事例元素:<requestLimitsmaxAllowedContentLength="2147483647" /> ,上传的大小将改为2G
注意: %windir%\system32\inetsrv\config\applicationhost.config 文件一定不要用其他机器的文件替换,否则IIS将无法启动
此文件记录了,当前IIS中所有Site , App pool的信息,还有一些与机器相关的配置。

2 修改web.config

<system.web>
     <
httpRuntimeexecutionTimeout="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 117:    <httpHandlers />

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

Line 119:    <httpRuntime executionTimeout="36000" maxRequestLength="4194304" />

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

Line 121:    <identity impersonate="true" />


3.  web.config下如果有如下节点(此节点是为IIS 7设计的) ,则修改
<requestLimitsmaxAllowedContentLength="2147483647" /> 单位与applicationhost.config中的<requestLimitsmaxAllowedContentLength="2147483647" />一致,它的最大值也只能为4294967295

<system.webServer>

<security>

<requestFiltering>

<requestLimitsmaxAllowedContentLength="2147483647" />

</requestFiltering>

</security>

</system.webServer>

 

 

总结:asp.net(IIS 7 and IIS 7.5)上传文件的最大值不能超过2GB


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap