ASP.Net 文件上传大小限制解决方案修改IIS7/7.5配置
来源:互联网 发布:雨人手机软件 编辑:程序博客网 时间:2024/05/22 16:55
IIS 7 默认文件上传大小时30M 要突破这个限制:
1. 修改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的信息,还有一些与机器相关的配置。
2 修改web.config <system.web> <httpRuntime executionTimeout="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:
<httpHandlers /> <customErrors mode="RemoteOnly" /> <httpRuntime executionTimeout="36000" maxRequestLength="4194304" /> <authentication mode="Windows" /> <identity impersonate="true" />
3. 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
看着步骤倒是也不算繁琐,可是本人照着步骤做了却没找到所说的<requestLimits>节点。无奈了
暮然回首,答案就在灯火阑珊处
其实上面分析的错误原因是对的,就是IIS中允许上传的最大文件默认是20多M,所以当上传较大的文件时才会报这个错误。后来用另外一种途径修改了这种设置。
目标是要修改文件C:\Windows\System32\inetsrv\config\schema\IIS_schema.xml 。绿色下划线部分使我们要修改的目标位置。
<element name="requestLimits"> <attribute name="maxAllowedContentLength" type="uint" defaultValue="30000000" /> <attribute name="maxUrl" type="uint" defaultValue="4096" /> <attribute name="maxQueryString" type="uint" defaultValue="2048" /> <element name="headerLimits"> <collection addElement="add" clearElement="clear" removeElement="remove"> <attribute name="header" type="string" required="true" isUniqueKey="true" validationType="nonEmptyString" /> <attribute name="sizeLimit" type="uint" required="true" /> </collection> </element>
问题在于,这个文件是只读的,即使用管理员权限也不能修改。要先修改文件的权限,然后去掉只读属性才可以。
1.右键文件->属性->安全,选中目标用户,点击高级,修改文件所有者;
2.确定后点击编辑,就可以修改当前用户的权限了,添加“写入”权限。至此,权限设置OK了。
3.将文件的只读属性去掉。
4.以管理员身份打开VS,然后在VS中编辑目标XML文件,修改所需位置即可。
5.上传个100M的视频,OK了。
至此,大功告成。
- IIS限制ASP.Net 文件上传大小解决方案,修改IIS7/7.5配置
- ASP.Net 文件上传大小限制解决方案修改IIS7/7.5配置
- ASP.Net 文件上传大小限制解决方案修改IIS7/7.5配置
- ASP.Net 文件上传大小限制解决方案修改IIS7/7.5配置
- ASP.Net 文件上传大小限制解决方案修改IIS配置
- Win2008或IIS7的文件上传大小限制解决方案,修改IIS77.5配置
- Windows server 2008修改IIS7的文件上传大小限制解决方案
- ASP.NET文件上传大小II限制修改
- Win2008或IIS7的文件上传大小限制解决方案
- 怎么修改asp文件上传大小限制?
- 更改ASP.NET文件上传大小限制
- 修改IIS7默认上传大小限制
- windows 7 IIS 7.5 ASP.Net 文件上传大小限制
- ASP.NET 修改文件上传尺寸限制
- FCKeditor 上传修改,添加对文件的类型以及大小的限制(ASP.NET C#)
- ASP.NET FCKeditor 上传修改,添加对文件的类型以及大小的限制
- 修改文件上传大小限制
- 修改文件上传大小限制
- ecmall get_users_count() fatal error
- SIP学习笔记
- 重新组织数据之十四 :Replace Type Code with Subclasses(以子类取代型别码)
- The C Programming Language 学习笔记
- DWR使用总结
- ASP.Net 文件上传大小限制解决方案修改IIS7/7.5配置
- android AIDL服务
- SIP协议简介
- php文件下载原理
- jQuery 入门教程(42): jQuery UI Tab 示例(二)
- Linux系统启动过程介绍
- 重新组织数据之十五 :Replace Type Code with State/Strategy(以State/strategy 取代型别码)
- BF and IA vulnerabilities in IBM Lotus Domino
- 黑马程序员_Java网络编程概述