本地 IIS 正常,部署至 Azure Web Apps / 雲服務後報 HTTP 500,疑似 <httpModules> 節點配置不兼容。
| 環境 | 管線模式 | 模組註冊節點 |
|---|---|---|
| 本地 IIS (經典/整合) | 可切換 | <system.web><httpModules> (經典)<system.webServer><modules> (整合) |
| Azure Web Apps | 強制整合管線 | 僅支援 <system.webServer><modules> |
<httpModules> 內容移至 <system.webServer><modules><system.webServer>
<modules runAllManagedModulesForAllRequests="true">
<add name="MyModule" type="Namespace.MyModule" />
</modules>
</system.webServer>
bin 目錄<system.web><httpModules> 導致整合管線忽略模組public 或命名空間拼寫錯誤<modules> 中指定 preCondition="managedHandler" 導致靜態資源也觸發模組(視需求調整)若為 Azure 雲服務,需在 WebRole.cs 的 OnStart 中配置啟動任務安裝模組,或使用啟動命令註冊。