ModuleAction Class

Represents a module entry in the <modules> section of a configuration file.

Syntax

class ModuleAction : CollectionElement  

Methods

This class contains no methods.

Properties

The following table lists the properties exposed by the ModuleAction class.

Name Description
Name A required unique read/write string value that contains the name of the module. The key property.
PreCondition A read/write string value that contains a comma-delimited list of values that represent preconditions for the module to be loaded. The possible values are listed later in the Remarks section.
Type A read/write string value that specifies a managed module's type.

Subclasses

This class contains no subclasses.

Remarks

Instances of this class are contained in the Modules property of the ModulesSection class.

The following table lists the possible values for the PreCondition property. The integratedMode and ISAPIMode settings are mutually exclusive. The default is null.

Value Description
bitness32 IIS loads the module in a 32-bit worker process. This setting applies only to 64-bit operating systems.
bitness64 IIS loads the module in a 64-bit worker process. This setting applies only to 64-bit operating systems.
integratedMode IIS loads the module only for application pools that run in integrated mode.
ISAPIMode IIS loads the module only for application pools that run in ISAPI mode.
runtimeVersion IIS loads the module only for application pools that use the specified .NET Framework version. To enable this precondition, append a string in the format vMajorVersion.MinorVersion to the string "runtimeVersion" (for example, "runtimeVersionv2.0").
managedHandler IIS loads the module only if the request is mapped to a managed handler. This setting can optimize performance by preventing static files from using managed modules for every request.

Example

The following example adds a managed module to the root Web.config file.

' 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!"  
  

Inheritance Hierarchy

CollectionElement

ModuleAction

Requirements

Type Description
Client - IIS 7.0 on Windows Vista
- IIS 7.5 on Windows 7
- IIS 8.0 on Windows 8
- IIS 10.0 on Windows 10
Server - IIS 7.0 on Windows Server 2008
- IIS 7.5 on Windows Server 2008 R2
- IIS 8.0 on Windows Server 2012
- IIS 8.5 on Windows Server 2012 R2
- IIS 10.0 on Windows Server 2016
Product - IIS 7.0, IIS 7.5, IIS 8.0, IIS 8.5, IIS 10.0
MOF file WebAdministration.mof

See Also

CollectionElement Class
GlobalModuleElement Class
GlobalModulesSection Class
ModulesSection Class