怎样修改web.config上传文件大小

怎样修改web.config上传文件大小,第1张

[html] view plain copy

Asp.Net配置Web.Config更改默认上传文件大小限制!(适用于win7\win2003的IIS)

[html] view plain copy

[csharp] view plain copy

<system.web>

<httpRuntime maxrequestLength="1073741824" executionTimeout="3600"/> <!--maxRequestLength就是文件的最大字符数,最大值不能超过2个G左右,executionTimeout是超时时间-->

<compilation debug="true" targetFramework="4.0" />

</system.web>

以下是网上其他人的答案,仅供参考:

修改IIS的applicationhost.config

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

找到: <requestFiltering>节点

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

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

注意: %windir%/system32/inetsrv/config/applicationhost.config 文件一定不要用其他机器的文件替换,否则IIS将无法启动

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

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

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

<system.webServer>

<security>

<requestFiltering>

<requestLimits maxAllowedContentLength="2147483647" />

</requestFiltering>

</security>

</system.webServer>

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

你是指你将这个文件上传之后不能下载吗?

如果是这样的话你可在iis中的Mine类型里将.config添加上,但是这样做会让用户可下下载你本机的config文件,这是很不安全的。


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/tougao/11690355.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2023-05-18
下一篇 2023-05-18

发表评论

登录后才能评论

评论列表(0条)

保存