檔案上傳,檔案太大遇到【HTTP 錯誤 404.13 - Not Found】,調整【maxAllowedContentLength】解決

  • 6117
  • 0

原本檔案上傳,遇到檔案太大的問題,調整【maxRequestLength】就可以解決,但是後來這個設定卻無效,原來...

緣起

小喵的使用者,最近上傳一個較大的檔案無法上傳成功,原本想說,這老問題,之前調整Web.Config中的

<system.web>
    <httpRuntime maxRequestLength="71680" executionTimeout="300" />
</system.web>

應該可以很快的打完收工,結束這回合,沒想到這招這時候失效了~被翻開陷阱卡,受到以下的攻擊

HTTP 錯誤 404.13 - Not Found
要求篩選模組設定為拒絕超過要求內容長度的要求。

 

IIS7以後的新設定:maxAllowedContentLength

在IIS7之後,有個新的設定可以限制上傳的大小,相關的設定如下:

	<system.webServer>
        <security>
            <requestFiltering>
                <requestLimits maxAllowedContentLength="70000000" />
            </requestFiltering>
        </security>
	</system.webServer>	

其單位為位元,因此如果要可上傳10MB,要自行先換算10*1024*1024

小喵自己筆記一下,也提供有類似問題的人參考
^_^

 

 


以下是簽名:


Microsoft MVP
Visual Studio and Development Technologies
(2005~2019/6) 
topcat
Blog:http://www.dotblogs.com.tw/topcat