共用方式為


ModuleAction 類別

表示組態檔區段中的模組專案 <modules>

Syntax

class ModuleAction : CollectionElement  

方法

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

屬性

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

名稱 描述
Name 包含模組名稱的必要唯一讀取/寫入 string 值。 索引鍵屬性。
PreCondition 讀取/寫入 string 值,其中包含以逗號分隔的值清單,這些值代表要載入之模組的前置條件。 後續的一節會列出可能的值。
Type 指定 Managed 模組類型的讀取/寫入 string 值。

子類別

這個類別不包含子類別。

備註

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

下表列出 屬性的 PreCondition 可能值。 integratedModeISAPIMode 設定互斥。 預設值為 null

描述
bitness32 IIS 會在 32 位背景工作進程中載入模組。 此設定僅適用于 64 位作業系統。
bitness64 IIS 會在 64 位背景工作進程中載入模組。 此設定僅適用于 64 位作業系統。
integratedMode IIS 只會針對以整合模式執行的應用程式集區載入模組。
ISAPIMode IIS 只會針對以 ISAPI 模式執行的應用程式集區載入模組。
runtimeVersion IIS 只會針對使用指定.NET Framework版本的應用程式集區載入模組。 若要啟用此前置條件,請以 vMajorVersion格式附加字串。MinorVersion 至字串 「runtimeVersion」 (例如 「runtimeVersionv2.0」) 。
managedHandler 只有在要求對應至 Managed 處理常式時,IIS 才會載入模組。 此設定可藉由防止靜態檔案針對每個要求使用 Managed 模組來優化效能。

範例

下列範例會將 Managed 模組新增至根Web.config檔案。

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the modules section.  
Set oModulesSection = _  
    oWebAdmin.Get("ModulesSection.Path=" & _  
        "'MACHINE/WEBROOT/APPHOST/Default Web Site',Location=''")  
  
' Get the ModuleAction class.  
Set oModuleAction = oWebAdmin.Get( "ModuleAction" )  
  
' Spawn a new instance of the ModuleAction class.  
Set oNewModule = oModuleAction.SpawnInstance_  
  
' Assign values to the new module's Name and Type properties.  
oNewModule.Name = "myNewModule2"  
oNewModule.Type = "System.Web.Profile.ProfileModule2"  
  
' Call the ModulesSection.Add method to add the new module.  
' If the module entry already exists, the error "Cannot create a file  
' when that file already exists." will be displayed.  
oModulesSection.Add "Modules", oNewModule  
  
' Alert user when done.  
WScript.Echo "Done!"  
  

繼承階層架構

CollectionElement

ModuleAction

規格需求

類型 描述
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

另請參閱

CollectionElement 類別
GlobalModuleElement 類別
GlobalModulesSection 類別
ModulesSection 類別