ModulesSection 类

表示配置文件中的模块节。

语法

class ModulesSection : ConfigurationSectionWithCollection  

方法

下表列出了 ModulesSection 类公开的方法。

名称 说明
添加 (继承自 ConfigurationSectionWithCollection。)
清除 (从 ConfigurationSectionWithCollection 继承。)
Get (从 ConfigurationSectionWithCollection 继承。)
GetAllowDefinition (继承自 ConfigurationSection。)
GetAllowLocation (从 ConfigurationSection 继承。)
删除 (从 ConfigurationSectionWithCollection 继承。)
RevertToParent (从 ConfigurationSection 继承。)
SetAllowDefinition (从 ConfigurationSection 继承。)
SetAllowLocation (从 ConfigurationSection 继承。)

属性

下表列出了 ModulesSection 类公开的属性。

名称 描述
Location (继承自 ConfigurationSection。)一个键属性。
Modules 一个由读/写 ModuleAction 值构成的数组。
Path (继承自 ConfigurationSection。)一个键属性。
RunAllManagedModulesForAllRequests 一个读/写 boolean 值。 如果针对每个请求运行所有托管模块,则为 true;否则,为 false。 默认为 false
SectionInformation (从 ConfigurationSection 继承。)

子类

此类不包含子类。

注解

此类包含在 Web 服务器上特定级别启用的全局模块,以及同时在同一级别执行请求工作的托管模块。

示例

以下示例展示了在 ApplicationHost.config 文件的 <modules> 节中的本机模块和托管模块。

' Connect to the WMI WebAdministration namespace.  
Set oWebAdmin = GetObject("winmgmts:root\WebAdministration")  
  
' Get the <modules> section.  
Set oSection = oWebAdmin.Get( _  
    "ModulesSection.Path='MACHINE/WEBROOT/APPHOST/',Location=''")  
  
' Display the native modules.  
WScript.Echo "---------- Native -------------"  
For Each oModule In oSection.Modules  
    If oModule.Type = "" Then  
        WScript.Echo "   " & oModule.Name  
    End If  
Next  
WScript.Echo   
  
' Display the managed modules.  
WScript.Echo "---------- Managed ----------"  
For Each oModule In oSection.Modules  
    If oModule.Type <> "" Then  
        If Len(oModule.Name) < 12 Then  
            WScript.Echo "   " & oModule.Name & _  
                vbTab & vbTab & vbTab & "[" & oModule.Type & "]"  
        ElseIf Len(oModule.Name) < 20 Then  
            WScript.Echo "   " & oModule.Name & _  
                vbTab & vbTab & "[" & oModule.Type & "]"  
        Else   
            WScript.Echo "   " & oModule.Name & _  
                vbTab & "[" & oModule.Type & "]"  
        End If  
    End If  
Next  

继承层次结构

ConfigurationSection

ConfigurationSectionWithCollection

ModulesSection

要求

类型 描述
客户端 - IIS 7.0(在 Windows Vista 上)
- IIS 7.5(在 Windows 7 上)
- IIS 8.0(在 Windows 8 上)
- IIS 10.0(在 Windows 10 上)
服务器 - IIS 7.0(在 Windows Server 2008 上)
- IIS 7.5(在 Windows Server 2008 R2 上)
- IIS 8.0(在 Windows Server 2012 上)
- IIS 8.5(在 Windows Server 2012 R2 上)
- IIS 10.0(在 Windows Server 2016 上)
产品 - IIS 7.0、IIS 7.5、IIS 8.0、IIS 8.5、IIS 10.0
MOF 文件 WebAdministration.mof

另请参阅

ConfigurationSectionWithCollection 类
GlobalModuleElement 类
GlobalModulesSection 类
ModuleAction 类