Ii有类似的问题:How to set the maxAllowedContentLength to 500MB while running on IIS7?
区别在于我已经修改了 web.config
以接受大小为2 Gb的文件,但是当尝试上传大文件时,我收到以下错误:
请求过滤模块配置为拒绝超出内容长度的请求 .
我的 web.config
是这样的:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.web>
<httpRuntime executionTimeout="999999" maxRequestLength="2097151"/>
<customErrors mode="Off"/>
<compilation debug="true" strict="false" explicit="true" targetFramework="4.0" />
<membership>
<providers>
<clear/>
</providers>
</membership>
<profile>
<providers>
<clear/>
</providers>
</profile>
<roleManager enabled="false">
<providers>
<clear/>
</providers>
</roleManager>
</system.web>
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="2097151" />
</requestFiltering>
</security>
</system.webServer>
当我尝试上传一个只有 131 MB
的文件时,我仍然收到错误 .
那么,我应该在 maxAllowedContentLength
设置中设置什么才能让人们上传超过100 MB的文件呢?
2 回答
虽然MaxRequestLength是千字节数,但maxAllowedContentLength是字节数 . 将其再次乘以1024,它应该可以正常工作 .
在Windows中键入 inetmgr 运行(WinKey r)在左侧面板上单击您的服务器名称,然后在 IIS 部分的右侧面板中双击请求筛选 . 在最右边的面板上单击 Edit Feature Settings... . 在 Request Limits 部分中,您可以更改 maxAllowedContentLength .
如果您想在您的某个网站中更改 maxAllowedContentLength ,请在左侧面板中选择 Sites 下的网站,然后按照与上述相同的方式进行更改 .