Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學

IIS 上傳 48KB 限制突破:UploadReadAheadSize、maxRequestLength、maxAllowedContentLength 三參數調整指南

編輯:XP 系統應用技巧

IIS 預設緩衝區 48KB (49152 bytes),超過大小的上傳會觸發 413 Request Entity Too Large 或瀏覽器重試死循環。三層參數調整可突破限制。

參數層級與適用版本

參數層級預設值最大值適用 IIS說明
UploadReadAheadSizeMetabase (IIS 6) / applicationHost.config (IIS 7+)49152 (48KB)4GBIIS 6/7/7.5/8/8.5/10IIS 讀取至緩衝區再傳給 ISAPI/ASP.NET 的前置大小。設 0 可直接串流至 ISAPI 擴充 (需應用支援)。
maxRequestLengthweb.config / machine.config4096 (4MB)2GBASP.NET (IIS 6/7+)ASP.NET 執行階段請求大小限制。
maxAllowedContentLengthapplicationHost.config / web.config (system.webServer/security/requestFiltering)30000000 (~30MB)4GBIIS 7+IIS 核心請求過濾模組限制。

調整建議

  1. 優先嘗試將 UploadReadAheadSize 設為 0 (若用 ISAPI 擴充處理上傳),或設為業務所需最大值 (如 104857600 = 100MB)。
  2. 同步調整 maxRequestLength (ASP.NET) 與 maxAllowedContentLength (IIS 7+),單位注意:前者 KB,後者 Bytes。
  3. 單站點調整:IIS 管理員 → 站點 → 「設定」/「要求篩選」 → 編輯功能設定。

安全警示

  • 過大值擴大攻擊面:惡意上傳巨型檔案耗盡頻寬/磁碟/CPU (DoS)。
  • 務必搭配驗證機制 (Windows 整合驗證/表單驗證/Client Certificate) 限制上傳者身分。
  • 設定合理上限 (如業務最大 50MB 設 60MB),避免預設 4GB 野蠻生長。

三參數聯動調整,配合身分驗證,即可安全支援大檔案上傳業務。

Copyright © Windows教程網 All Rights Reserved