您的位置:首页 > 其它

Windows Server 2008 IIS上传文件大小设置

2014-02-08 21:35 225 查看
Windows server 2008中的IIS7.0的asp.net写的上传,上传大文件有几个地方需要设置

1.系统本身

修改C:/Windows/System32/inetsrv/config/schema/IIS_schema.xml文件(修改该文件需要获得这个文件的控制权,需要先获得这个文件的所有者,所有者是TrustedInstaller,改成administrator后,把属性只读改掉,就可以改了。但是再把所有者改回TrustedInstaller就改不回去了,不知道为什么),找到maxAllowedContentLength, 其默认值为30000000,即30M,加一个0 就变成了 300MB 了就应该够用了,如果不起作用,则需要重启
IIS 7即可:

<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>

2.IIS7.0本身

打开IIS管理器–双击“IIS”中的“ASP”– 打开“配置 ASP 应该程序的属性”–展开“限制属性”;修改“最大请求实体主体限制”的值,默认值为200000(即不到200KB);把它修改为你想修改的大小

3.asp.net本身web.config

单位是KB,1024KB=1MB.

<system.web>

<!-- 设置可上传的最大文件大小 -->

<httpRuntime maxRequestLength="1024" requestValidationMode="2.0" />

</system.web>

三个都改完后,发现还是不行,然后我发现是我的web.config中的代码有错误。这个段代码必须放在<loctaion>...</location>中,而不是<location path="ajaxpro">

我的配置中不知道为什么有个<location path="ajaxpro">.我把其中的<httpRuntime....>代码取出来,再写一个<location>就好了。

<location path="ajaxpro">

<system.web>

<httpHandlers>

......

<location>

<system.web>

<httpRuntime executionTimeout="8000" maxRequestLength="50000" useFullyQualifiedRedirectUrl="false"/>

</system.web>

</location>

我原来是Xp的系统,换成win7后,发布完成,本地电脑运行又发现错误了。按照这个流程就解决了。
/article/1978092.html
改过来后,又发现错误,按照下边的文章就解决了。
/article/4879811.html
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: