共用方式為


httpModules 的 add 項目 (ASP.NET 設定結構描述)

將 httpModules 項目加入至應用程式。

<add name="ModuleName"
   type=".NET Class, Assembly [,Version=version number]
      [,Culture=culture] [,PublicKeyToken=token]"/>

屬性和項目

下列各節將說明屬性、子項目和父項目。

屬性

屬性

說明

name

必要屬性。

提供模組的易記名稱,如此可讓您將事件處理常式關聯至 global.asax 檔案中的模組事件。

type

必要屬性。

指定逗號分隔的類別/組件組合,其中含有版本、文化特性和公開金鑰語彙基元。 ASP.NET 會先在應用程式的私用 \bin 目錄搜尋組件 DLL,然後在系統組件快取中搜尋。

子項目

無。

父項目

項目

說明

configuration

指定 Common Language Runtime 和 .NET Framework 應用程式所使用之每個組態檔中的根項目 (Root Element)。

system.web

指定 ASP.NET 組態區段的根項目。

httpModules

設定應用程式中的 HTTP 模組。

備註

會依照由上而下的順序來處理 add 指示詞。 如果有兩個或更多的 add 子標記指定相同的動作/路徑組合,則最後的 add 會覆寫其他的組合。

預設的組態

下列預設 add 項目是在 .NET Framework 1.1 版中的 Machine.config 檔案中設定。

<add name="OutputCache" type="System.Web.Caching.OutputCacheModule"/>
<add name="Session" type="System.Web.SessionState.SessionStateModule"/>
<add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule"/>
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule"/>
<add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule"/>
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule"/>
<add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule"/>
<add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, 
     Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

下列預設 add 項目是在 .NET Framework 1.0 版中的 Machine.config 檔案中設定。

<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" />
<add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" />
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
<add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
<add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule" />

下列預設 add 項目是在 .NET Framework 2.0 版中的根 Web.config 檔中設定。

<add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
<add name="Session" type="System.Web.SessionState.SessionStateModule" />
<add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" />
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
<add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule" />
<add name="RoleManager" type="System.Web.Security.RoleManagerModule" />
<add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
<add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule" />
<add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule" />
<add name="Profile" type="System.Web.Profile.ProfileModule" />

範例

下列程式碼範例將示範如何將 httpModules 項目加入至應用程式。

<configuration>
   <system.web>
      <httpModules>
         <add name="OutputCache"
              type="System.Web.Caching.OutputCacheModule, System.Web,
                    Version=1.0.2800.0, Culture=neutral,
                    PublicKeyToken=b03f5f7f11d50a3a"/>
      </httpModules>
   <system.web>
</configuration>

項目資訊

組態區段處理常式

System.Web.Configuration.HttpModulesSection

組態成員

SystemWebSectionGroup.HttpModules

可設定的位置

Machine.config

根層次的 Web.config

應用程式層級的 Web.config

虛擬或實體目錄層級的 Web.config

需求

Microsoft Internet Information Services (IIS) 5.0、5.1 或 6.0 版

.NET Framework 1.0、1.1 或 2.0 版

Microsoft Visual Studio 2003 或 Visual Studio 2005

請參閱

工作

HOW TO:鎖定 ASP.NET 組態設定

參考

httpModules 項目 (ASP.NET 設定結構描述)

system.web 項目 (ASP.NET 設定結構描述)

<configuration> 項目

httpModules 的 clear 項目 (ASP.NET 設定結構描述)

httpModules 的 remove 項目 (ASP.NET 設定結構描述)

System.Configuration

System.Web.Configuration

概念

ASP.NET 組態概觀

ASP.NET Web 伺服器控制項和瀏覽器能力

保護 ASP.NET 組態

ASP.NET 組態案例

其他資源

ASP.NET 組態檔

ASP.NET 組態設定

一般組態設定 (ASP.NET)

ASP.NET 組態 API