Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> 電腦軟體教學 >> 伺服器技術 >> 關於伺服器

解決「定義了重複的 system.web.extensions/scripting/scriptResourceHandler」錯誤

編輯:關於伺服器

錯誤場景

在 Windows Server 2008 + IIS 7 環境部署 ASP.NET Web Service 時,瀏覽器顯示 HTTP 500 錯誤,詳細訊息指出 web.config 中重複定義了 system.web.extensions/scripting/scriptResourceHandler 區段。

重複區段錯誤截圖

根因分析

.NET Framework 4.0 的機器層級設定檔 machine.config (路徑通常為 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\machine.config) 已預先註冊了 AJAX 相關處理常式。專案本身的 web.config 若再次宣告相同區段,便會衝突。

解決方案:在 web.config 中移除重複區段

於專案 web.config 的 <system.webServer> 或 <system.web> 區塊中,使用 <remove> 移除衝突的處理常式與模組註冊:

<system.webServer>
  <handlers>
    <remove name="ScriptResourceHandler" />
    <!-- 其他可能重複的 handlers -->
  </handlers>
  <modules>
    <remove name="ScriptModule" />
    <!-- 其他可能重複的 modules -->
  </modules>
</system.webServer>

web.config 移除重複項示例

注意事項

  • 註解掉或移除時,務必保留結構完整,不要誤刪結尾的 </system.webServer> 等標籤。
  • 若專案需相容 .NET 3.5 舊版,可考慮在 <configSections> 中清除重複區段定義,但通常移除 handlers/modules 即可。
Copyright © Windows教程網 All Rights Reserved