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

IIS 7.5 (Win7) 顯示 ASP 詳細錯誤資訊:三種設定法完整教學

編輯:Windows 7 系統介紹

Win7 內建 IIS 7.5 預設隱藏 ASP 錯誤細節,僅顯示「請聯繫管理員」。開發除錯時需開啟詳細錯誤,上線前建議關閉以減少攻擊面。

方法一:命令列一鍵設定(最快)

REM 開啟詳細錯誤
%windir%\system32\inetsrv\appcmd set config -section:asp -scriptErrorSentToBrowser:true

REM 關閉詳細錯誤(上線前執行)
%windir%\system32\inetsrv\appcmd set config -section:asp -scriptErrorSentToBrowser:false

需以系統管理員身分執行 CMD。

方法二:修改 applicationHost.config

  1. 以記事本開啟 %windir%\system32\inetsrv\config\applicationHost.config。
  2. 尋找 <system.webServer> 區段下的 <asp> 元素。
  3. 加入屬性:scriptErrorSentToBrowser="true"。
  4. 儲存檔案,IIS 即時生效。

方法三:IIS 管理員圖形介面

  1. 控制台 → 系統及安全性 → 系統管理工具 → IIS 管理員。
  2. 選取網站 → 功能檢視雙擊「ASP」。
  3. 展開「偵錯屬性」→「將指令碼錯誤傳送給瀏覽器」設為 True。
  4. 點擊右側「套用」。

前提:已在「開啟或關閉 Windows 功能」→ IIS → 開發應用程式 → ASP 勾選安裝。

必要的瀏覽器設定

IE/Edge 需同時關閉「顯示易懂 HTTP 錯誤訊息」:
Internet 選項 → 進階 → 取消勾選「顯示易懂 HTTP 錯誤訊息」。

安全提醒

開發完成後務必執行 scriptErrorSentToBrowser:false 關閉詳細錯誤,避免洩露路徑、資料庫連線字串等敏感資訊。

Copyright © Windows教程網 All Rights Reserved