Export (0) Print
Expand All
Expand Minimize

ModuleAction Class [IIS 7 and higher]

IIS 7.0

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

class ModuleAction : CollectionElement

This class contains no methods.

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.

This class contains no subclasses.

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.

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

Type

Description

Client

Requires IIS 7 on Windows Vista.

Server

Requires IIS 7 on Windows Server 2008.

Product

IIS 7

MOF file

WebAdministration.mof

Community Additions

ADD
Show:
© 2014 Microsoft