Asp.net
如何在 IIS7 上執行時將 maxAllowedContentLength 設置為 500MB?
我將 maxAllowedContentLength 更改為
<security> <requestFiltering> <requestLimits maxAllowedContentLength="5024000000" /> </requestFiltering> </security>在我的 web.config 中,但在 IIS7 上執行時出現此錯誤:
“maxAllowedContentLength”屬性無效。不是有效的無符號整數
但是當我在 VS 伺服器中執行時,它執行正常,沒有任何錯誤。
如何配置我的網站以允許上傳大小為 500MB 的文件,而在 IIS7 上沒有此問題?
根據MSDN
maxAllowedContentLengthhas typeuint,它的最大值是 4,294,967,295 bytes = 3,99 gb所以它應該可以正常工作。
另請參閱請求限製文章。如果根本沒有配置相應的部分,IIS 是否會返回這些錯誤之一?
另請參閱:超出最大請求長度
.Net 中的請求限制可以從兩個屬性一起配置:
第一的
Web.Config/system.web/httpRuntime/maxRequestLength- 計量單位:千字節
- 預設值 4096 KB (4 MB)
- 最大限度。值 2147483647 KB (2 TB)
第二
Web.Config/system.webServer/security/requestFiltering/requestLimits/maxAllowedContentLength(以字節為單位)- 計量單位:字節
- 預設值 30000000 字節 (28.6 MB)
- 最大限度。值 4294967295 字節 (4 GB)
參考:
- <http://www.whatsabyte.com/P1/byteconverter.htm>
- <https://www.iis.net/configreference/system.webserver/security/requestfiltering/requestlimits>
例子:
<location path="upl"> <system.web> <!--The default size is 4096 kilobytes (4 MB). MaxValue is 2147483647 KB (2 TB)--> <!-- 100 MB in kilobytes --> <httpRuntime maxRequestLength="102400" /> </system.web> <system.webServer> <security> <requestFiltering> <!--The default size is 30000000 bytes (28.6 MB). MaxValue is 4294967295 bytes (4 GB)--> <!-- 100 MB in bytes --> <requestLimits maxAllowedContentLength="104857600" /> </requestFiltering> </security> </system.webServer> </location>
