HTTP 模組實作 IHttpModule 介面,掛載於 ASP.NET 請求管線,能攔截每個請求的生命週期事件(BeginRequest、AuthenticateRequest、EndRequest 等),實現跨頁面的橫切關注點。
.aspx、.ashx)。BeginRequest 檢查 Token、IP 黑白名單,未通過則直接 Response.End()。PostRequestHandlerExecute 注入共用 HTML 片段(如版權宣告、追蹤碼)。IHttpModule,於 Init(HttpApplication context) 訂閱所需事件。context_BeginRequest)。Dispose()。web.config <httpModules> 區段註冊(IIS 7+ 整合模式請註冊於 <system.webServer><modules>)。
掌握事件順序可精準決定在何處攔截/修改請求與回應。