共用方式為


HandlerAction 類別

公開處理常式的組態設定。

Syntax

class HandlerAction : CollectionElement  

方法

這個類別不包含任何方法。

屬性

下表列出 類別所 HandlerAction 公開的屬性。

名稱 描述
AllowPathInfo 讀取/寫入 boolean 值。 true 如果處理常式會在統一資源識別項 (URI) 中處理完整路徑資訊,則為 ;否則為 false 。 預設值為 false

例如,當 時 true ,這個屬性會允許處理常式處理完整路徑,例如 「/vdir/myisapi.dll/zip」;當 時 false ,此屬性只允許部分路徑 「/zip」。
Modules 讀取/寫入 string 值,指定您要對應檔案或副檔名的模組。 預設值為 null
Name 必要的唯一讀取/寫入 string 值,指定處理常式對應的唯一名稱。 唯一的索引鍵屬性。
Path 讀取/寫入 string 值,指定要處理之檔案類型副檔名的副檔名或檔案名。 預設值為 null
PreCondition 可讀寫 string 值,選擇性地指定處理常式可執行檔條件。 後續的一節會列出可能的值。
RequireAccess 指定處理常式存取需求的讀取/寫入 sint32 列舉。 後續的一節會列出可能的值。
ResourceType 讀取/寫入 sint32 列舉,指定處理常式的對應類型。 後續的一節會列出可能的值。
ResponseBufferLimit 讀取/寫入 uint32 值,可設定要求處理常式之回應緩衝區的大小上限,以位元組為單位。 如果在PagesSection類別的 屬性中 Buffer 啟用回應緩衝,則 ResponseBufferLimit 屬性會控制 ASP 頁面可以在排清發生之前寫入回應緩衝區的最大位元組數目。 預設值為 4194304 個位元組。
ScriptProcessor 讀取/寫入 string 值,指定適當情況下處理要求之 ISAPI 副檔名的完整路徑.dll檔案或 CGI .exe 檔案。 如果您指定此屬性,則必須在 屬性中 Modules 指定 「ISAPIModule」 或 「CGIModule」。 預設值為 null
Type 可讀寫 string 值,指定 Managed 處理常式的命名空間路徑。 指定的類型必須是全域組件快取、應用程式 Bin 目錄或app_code目錄中的有效 Managed 類型。 預設值為 null
Verb 讀取/寫入 string 值,指定以逗號分隔的動詞清單。 如果您想要將對應套用至特定要求類型,請使用此屬性。 預設值為 null

子類別

這個類別不包含子類別。

備註

這個類別的實例包含在 HandlersHandlersSection 類別的 屬性中。

下表列出 屬性的 Precondition 可能值。 預設為 null

注意

前置條件的評估是元件的邏輯 AND 。 因為任何未知的前置條件都會評估為 false ,所以存在未知的前置條件會導致忽略未知的前置條件。

描述
appPoolName=pool1;pool2 處理常式將用於以分號分隔清單命名的任何應用程式集區。
appPoolName!=pool1;pool2 處理常式不會用於以分號分隔清單命名的任何應用程式集區。
bitness32 處理常式專案只適用于 32 位背景工作進程。 針對 64 位電腦,您應該使用此值來指定哪些應用程式集區以 32 位模式執行。
bitness64 處理常式只適用于 64 位背景工作進程。 針對 64 位電腦,您應該使用此值來指定哪些應用程式集區以 64 位模式執行。
integratedMode 處理常式只會用於整合模式中的應用程式集區。
ISAPIMode 處理常式只會用於 ISAPI 模式中的應用程式集區。
runtimeVersion 處理常式只會用於載入特定版本的 Common Language Runtime (CLR) 的應用程式集區。 若要啟用此前置條件,請以 vMajorVersion格式附加字串。MinorVersion 至字串 「runtimeVersion」 (例如 「runtimeVersionv2.0」) 。

下表列出 屬性的 RequireAccess 可能值。 預設值為 3 (Script) 。

注意

HandlersSection類別之 屬性中的 AccessPolicy 設定會決定允許哪些許可權,因此允許執行哪些處理常式。

關鍵字 描述
0 None 處理常式沒有存取需求。
1 Read 處理常式需要讀取權限。
2 Write 處理常式需要寫入權限。
3 Script 處理常式需要腳本許可權。
4 Execute 處理常式需要可執行檔許可權。

下表列出 屬性的 ResourceType 可能值。 預設值為 3 (Unspecified) 。

注意

此屬性標示為 IIS 管理員中的 路徑類型

關鍵字 描述
0 File 對應適用于檔案。 如果連入要求未對應至磁片上的實體檔案,則不會將要求傳遞至處理常式。
1 Directory 對應適用于目錄。 如果連入要求未對應至磁片上的實體資料夾,則不會將要求傳遞至處理常式。
2 Either 對應適用于檔案或目錄。 如果連入要求未對應至磁片上的實體檔案或資料夾,則不會將要求傳遞至處理常式。
3 Unspecified 未指定對應類型。 不論要求是否對應至磁片上的實體檔案或資料夾,要求都會傳遞至處理常式。 如果您要將處理常式對應至檔案名 (,例如「MyHandler.axd」) 您知道的磁片上不存在,請使用此設定。

範例

下列範例會將三個不同的處理常式類別新增至 <handlers> 區段:舊版腳本對應處理常式、兩個原生模組處理常式和 Managed 處理常式。

注意

新增或移除組態專案會變更基礎組態區段,但不是代表組態區段之腳本中的物件變數。 為了讓變更出現在腳本中,您必須在進行變更之後,在物件變數上呼叫 WMI Refresh_ 方法。 這會使用組態存放區的最新資料來更新物件變數。

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the <handlers> section.  
Set oSite = oWebAdmin.Get("Site.Name='Default Web Site'")  
oSite.GetSection "HandlersSection", oHandlersSection  
  
' Display the old list of handlers.  
WScript.Echo "---[Old Handler List]---"  
Call DisplayHandlers  
  
' Create a legacy script map handler.  
' The required properties are Name, Modules, and ScriptProcessor.  
Set oHandler = oWebAdmin.Get("HandlerAction").SpawnInstance_  
oHandler.Name = "ASPClassic"   
oHandler.Path="*.asp"   
oHandler.Verb="GET,HEAD,POST"   
oHandler.Modules="ISAPIModule"   
oHandler.ResourceType= 0 '0 is "File"  
oHandler.ScriptProcessor = "%windir%\system32\inetsrv\asp.dll"  
  
' Add the handler to the <handlers> section.  
oHandlersSection.Add "Handlers", oHandler  
  
' Create a native module handler for static files.  
' The required properties are Name, Modules, and Path.  
Set oHandler = oWebAdmin.Get("HandlerAction").SpawnInstance_  
oHandler.Name = "StaticFile"   
oHandler.Path="*"   
oHandler.Verb="*"   
oHandler.Modules="StaticFileModule,DefaultDocumentModule,DirectoryListingModule"  
oHandler.ResourceType=2  
oHandler.RequireAccess=1  
  
' Add the handler to the <handlers> section.  
oHandlersSection.Add "Handlers", oHandler  
  
' Create a native module handler for ISAPI DLLs.  
' The required properties are Name, Modules, and Path.  
oHandler.Name = "ISAPI-dll"   
oHandler.Path="*.dll"   
oHandler.Verb="*"   
oHandler.Modules="ISAPIModule"  
oHandler.ResourceType=0  
oHandler.RequireAccess=4  
oHandler.AllowPathInfo=True  
  
' Add the handler to the <handlers> section.  
oHandlersSection.Add "Handlers", oHandler  
  
' Add a managed handler.  
' The required properties are Name, Path, and Type.   
Set oHandler = oWebAdmin.Get("HandlerAction").SpawnInstance_  
oHandler.Name = "TraceHandler-Integrated"   
oHandler.Path="trace.axd"   
oHandler.Verb="GET,HEAD,POST"   
oHandler.Type="System.Web.Handlers.TraceHandler"  
oHandler.PreCondition="integratedMode"  
  
' Add the handler to the <handlers> section.  
oHandlersSection.Add "Handlers", oHandler  
  
' Call the WMI Refresh_ method to update the oHandlersSection object variable.  
oHandlersSection.Refresh_  
  
' Display the new list of handler names.   
WScript.Echo "---[New Handler List]---"  
Call DisplayHandlers  
  
' Provide a sub to display the handler names.  
Sub DisplayHandlers  
    For Each oHandler In oHandlersSection.Handlers  
         WScript.Echo "Name: " & oHandler.Name  
    Next  
    WScript.Echo  
End Sub  
  

繼承階層架構

CollectionElement

HandlerAction

規格需求

類型 描述
Client - Windows Vista 上的 IIS 7.0
- Windows 7 上的 IIS 7.5
- Windows 8 上的 IIS 8.0
- Windows 10上的 IIS 10.0
伺服器 - Windows Server 2008 上的 IIS 7.0
- Windows Server 2008 R2 上的 IIS 7.5
- Windows Server 2012 上的 IIS 8.0
- Windows Server 2012 R2 上的 IIS 8.5
- Windows Server 2016上的 IIS 10.0
產品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 檔案 WebAdministration.mof

另請參閱

AccessSection 類別
CollectionElement 類別
HandlersSection 類別
IScriptMapInfo::GetAllowPathInfoForScriptMappings 方法