.NET上傳大檔案時提示Maximum request length exceeded錯誤的解決方法
阿新 • • 發佈:2019-02-09
使用IIS託管應用程式時,當我們需要上傳大檔案(4MB以上)時,應用程式會提示Maximum request length exceeded的錯誤資訊。該錯誤資訊的翻譯:超過最大請求長度。
解決方法:
使用IIS來託管應用程式,預設的上傳檔案大小為4MB。我們需要增加請求大小,在專案的Web.config配置檔案中新增以下配置項資訊:
<configuration> <system.web> <httpRuntime maxRequestLength="1048576" /> </system.web> </configuration>
對於IIS7及以上版本,還需要新增以下配置項資訊:
<system.webServer>
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="1073741824" /></requestFiltering>
</security>
</system.webServer>
注意:
maxRequestLength以千位元組(KB)度量。
maxAllowedContentLength以位元組(bytes)度量。
所以上述例項中,我們將請求大小增加到了1GB。