2
我將此添加到我的web.config
文件:如何限制文件上傳的大小但顯示有意義的響應?
<httpRuntime maxRequestLength="40960"/> <!-- Limit to 40 megabytes -->
,當我嘗試上載的東西超過40兆大,我得到這個在Firefox:
The connection was reset
The connection to the server was reset while the page was loading.
* The site could be temporarily unavailable or too busy. Try again in a few
moments.
* If you are unable to load any pages, check your computer's network
connection.
* If your computer or network is protected by a firewall or proxy, make sure
that Firefox is permitted to access the Web.
有一些方法也從中受益這內置的文件大小限制,但實際上顯示一個不錯的錯誤頁面?當然,我可以在控制器中執行此檢查,但此時流量已耗盡,因爲大文件已到達我的服務器。
if (image.ContentLength > 40960) // 'image' is HttpPostedFileBase
有什麼建議嗎?