public
class
MyHttpModule : IHttpModule
{
public
void
Dispose()
{
}
public
void
Init(HttpApplication context)
{
context.BeginRequest += context_BeginRequest;
}
protected
void
context_BeginRequest(
object
sender, EventArgs e)
{
var context = sender
as
HttpApplication;
context.Response.Clear();
context.Response.Write(
"HttpModule"
);
context.Response.End();
}
}
<httpHandlers>
<remove verb=
"*"
path=
"*.asmx"
/>
<add verb=
"*"
path=
"*.asmx"
validate=
"false"
type=
"System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
/>
<add verb=
"*"
path=
"*_AppService.axd"
validate=
"false"
type=
"System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
/>
<add verb=
"GET,HEAD"
path=
"ScriptResource.axd"
type=
"System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
validate=
"false"
/>
</httpHandlers>
<httpModules>
<add name=
"MyHttpModule"
type=
"WebApplication.MyHttpModule, WebApplication"
/>
<add name=
"ScriptModule"
type=
"System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
/>
</httpModules>
訪問網站可以發現頁面輸出如下,說明程序經過了HttpModule
<!--
The system.webServer section is required for running ASP.NET AJAX under Internet
Information Services 7.0. It is not necessary for previous version of IIS.
-->
這樣就大概明白意思是iis7.0之後有部分web配置移動到system.webServer中。查閱相關得到答案確實如此 詳細資料見
於是在<system.webServer> <modules>中加入配置如下,刷新頁面,頁面能夠輸出字符HttpModule,證明成功了。
<system.webServer>
<validation validateIntegratedModeConfiguration=
"false"
/>
<modules>
<remove name=
"ScriptModule"
/>
<add name=
"MyHttpModule"
type=
"WebApplication.MyHttpModule, WebApplication"
/>
<add name=
"ScriptModule"
preCondition=
"managedHandler"
type=
"System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"
/>
</modules>
由於在升級過程成有一個站點出現 HTTP 錯誤 500.22 - Internal Server Error 檢測到在集成的托管管道模式下不適用的 ASP.NET 設置
當時在比較急的情況下就直接刪除了 <system.web> 的子節點<httpModules> 程序正常運行。後面通過仔細和正常的站點對比是發現是缺少 <validation validateIntegratedModeConfiguration="false"/> 這個導致,這個主要作用是設置不檢測 <system.web>中的配置
經過這今天的折騰終於是對iis7.5上的部署有了一定了解了。