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

解決 IIS 6.0 ASP 上傳 200KB 限制:修改 Metabase.xml 突破 AspMaxRequestEntityAllowed

編輯:Windows 2003 教學

問題現象

Windows Server 2003 + IIS 6.0 預設限制 ASP 上傳檔案大小為 204,800 位元組(200KB)。超過此限制會出現錯誤:
Request 對象 錯誤 ASP 0104 : 80004005
或上傳看似成功但找不到檔案。ASP.NET (.aspx) 不受此限制。

根本原因

IIS 6.0 為安全考量,在 Metabase.xml 中設定 AspMaxRequestEntityAllowed = 204800。舊版 IIS 無此限制。

解決步驟(圖文詳解)

  1. 開啟「Internet 資訊服務 (IIS) 管理員」→ 右鍵本地電腦 →「內容」。
  2. 勾選「允許直接編輯組態資料庫」,確定。
  3. 「服務」管理工具中停止 IIS Admin Service(會連帶停止 WWW、FTP、SMTP 等服務)。
  4. 用記事本開啟 C:\Windows\System32\Inetsrv\MetaBase.xml。
  5. 搜尋 AspMaxRequestEntityAllowed,預設值 204800。
  6. 修改為所需值(位元組),例如 51200000(50MB)或 104857600(100MB)。
  7. 儲存檔案,重新啟動 IIS Admin Service(相依服務會自動跟著啟動)。

驗證

重新測試 ASP 上傳頁面,上傳大於 200KB 的檔案應可成功。

補充說明

  • ASP.NET 另行設定:web.config 中 <httpRuntime maxRequestLength="102400" />(單位 KB,預設 4096 KB = 4MB)。
  • 安全考量:放大上傳限制會增加 DoS 風險,建議搭配 URLScan/Request Filtering 限制副檔名、掃毒上傳檔、隔離上傳目錄權限(可寫不可執行)。
  • IIS 7.0+:改在 applicationHost.config 或 web.config 設定 <security><requestFiltering><requestLimits maxAllowedContentLength="..." /></requestFiltering></security>(單位位元組)。

快速指令腳本(適用自動化部署)

@echo off
net stop iisadmin /y
powershell -command "(gc C:\Windows\System32\Inetsrv\MetaBase.xml) -replace 'AspMaxRequestEntityAllowed=\"204800\"', 'AspMaxRequestEntityAllowed=\"51200000\"' | sc C:\Windows\System32\Inetsrv\MetaBase.xml"
net start iisadmin
net start w3svc

總結

修改 Metabase.xml 的 AspMaxRequestEntityAllowed 是突破 IIS 6.0 ASP 上傳限制的標準方法,操作前務必停止 IIS Admin Service,修改後重啟服務生效。生產環境請評估風險並配合安全防護措施。

Copyright © Windows教程網 All Rights Reserved