萬盛學電腦網

您现在的位置: 萬盛學電腦網 >> 程式設計 >  >> 網路程式設計 >> 程式語言綜合

Win7 IIS 7.5 解除上傳大小限制:雙重配置詳解 (ASP 0104 錯誤)

Windows 7 IIS 7.5 預設限制上傳檔案大小,導致 ASP 上傳大檔案報錯 Request 對象 錯誤 ASP 0104 : 800004005。需同時修改兩處配置才能生效。

錯誤現象

上傳超過 200KB 檔案時失敗,經典 ASP 程式碼無誤,純屬 IIS 限制。

解決方案:雙重修改

1. ASP 限制屬性:最大請求實體主體限制

  1. 開啟「Internet Information Services (IIS) 管理員」。
  2. 選中網站 → 雙擊「ASP」。
  3. 展開「限制屬性」→ 找到「最大請求實體主體限制」。
  4. 預設 200000 (bytes, 約 200KB) → 修改為所需值 (如 314572800 = 300MB)。
  5. 點擊「套用」。

2. 要求篩選:允許的最大內容長度

  1. 在 IIS 管理員中選中網站 → 雙擊「要求篩選」。
  2. 右側動作欄點擊「編輯功能設定」。
  3. 修改「允許的最大內容長度」(Bytes),預設 30000000 (≈30MB) → 改為 314572800 (300MB)。
  4. 確定並重新啟動 IIS (或回收應用程式集區)。

關鍵: 兩處必須同時修改,否則仍受限於較小值。

替代方案:修改 applicationHost.config (不推薦手動編輯)

路徑:C:\Windows\System32\inetsrv\config\applicationHost.config

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="314572800" />
    </requestFiltering>
  </security>
  <asp>
    <limits maxRequestEntityAllowed="314572800" />
  </asp>
</system.webServer>

需管理員權限編輯,且格式錯誤會導致 IIS 無法啟動,建議透過 GUI 操作。

驗證方法

上傳 50MB、100MB 測試檔案,確認無錯誤並檔案完整。

補充:ASP.NET (Web.config)

若為 ASP.NET 應用,另需在 web.config 設定:

<system.web>
  <httpRuntime maxRequestLength="307200" executionTimeout="600" /> <!-- KB -->
</system.web>
<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="314572800" /> <!-- Bytes -->
    </requestFiltering>
  </security>
</system.webServer>

注意單位差異:maxRequestLength 以 KB 為單位,maxAllowedContentLength 以 Bytes 為單位。

copyright © 萬盛學電腦網 all rights reserved