HandlersSection Class
Stores the handlers for a URL.
Syntax
class HandlersSection : ConfigurationSectionWithCollection
Methods
The following table lists the methods exposed by the HandlersSection
class.
Name | Description |
---|---|
Add | (Inherited from ConfigurationSectionWithCollection.) |
Clear | (Inherited from ConfigurationSectionWithCollection .) |
Get | (Inherited from ConfigurationSectionWithCollection .) |
GetAllowDefinition | (Inherited from ConfigurationSection.) |
GetAllowLocation | (Inherited from ConfigurationSection .) |
Remove | (Inherited from ConfigurationSectionWithCollection .) |
RevertToParent | (Inherited from ConfigurationSection .) |
SetAllowDefinition | (Inherited from ConfigurationSection .) |
SetAllowLocation | (Inherited from ConfigurationSection .) |
Properties
The following table lists the properties exposed by the HandlersSection
class.
Name | Description |
---|---|
AccessPolicy |
A sint32 that specifies the access policy for handlers. The possible values are listed later in the Remarks section. |
Handlers |
An array of HandlerAction objects. |
Location |
(Inherited from ConfigurationSection .) A key property. |
Path |
(Inherited from ConfigurationSection .) A key property. |
SectionInformation |
(Inherited from ConfigurationSection .) |
Subclasses
This class contains no subclasses.
Remarks
This class corresponds to the <handlers>
section in the ApplicationHost.config file.
The following table lists the possible values for the AccessPolicy
property. The default is 1 (Read
).
Value | Keyword | Description |
---|---|---|
0 | None |
Handlers are allowed no rights. |
1 | Read |
Handlers are allowed read permission for files or contents of folders. Note: This flag was named AccessRead in IIS 6.0. |
2 | Write |
Handlers are allowed to write to enabled directories on the server or to change the content of a write-enabled file. Note: This flag was named AccessWrite in IIS 6.0. |
4 | Execute |
Handlers are allowed to execute files or contents of folders, regardless of file type. Note: This flag was named AccessExecute in IIS 6.0. |
16 | Source |
Handlers are allowed to access script source code if either the Read or Write flag is also set. If Read is set, handlers can read the source code. If Write is set, handlers can write to the source code. The Source flag is not available if neither Read nor Write is set. Note: This flag was named AccessSource in IIS 6.0. |
512 | Script |
The handler is allowed to execute scripts. Note: This flag was named AccessScript in IIS 6.0. |
1024 | NoRemoteWrite |
The handler is not allowed to write remotely. Remote requests to create or change files are denied. If the Write flag is also set, requests from only the computer that is running the IIS Web server will succeed. Note: This flag was named AccessNoRemoteWrite in IIS 6.0. |
4096 | NoRemoteRead |
The handler is not allowed to read remotely. Remote requests to view files are denied. If the Read flag is also set, requests from only the computer that is running the IIS Web server will succeed. Note: This flag was named AccessNoRemoteRead in IIS 6.0. |
8192 | NoRemoteExecute |
The handler is not allowed to execute remotely. Remote requests to execute applications are denied. If the Execute flag is also set, requests from only the computer that is running the IIS Web server will succeed. Note: This flag was named AccessNoRemoteExecute in IIS 6.0. |
16384 | NoRemoteScript |
The handler is not allowed to execute scripts remotely. Remote requests to execute dynamic content are denied. If the Script flag is also set, requests from only the computer that is running the IIS Web server will succeed. Note: This flag was named AccessNoRemoteScript in IIS 6.0. |
Example
The following examples add and remove a handler from the <handlers>
section.
Note
Adding or removing a configuration element changes the underlying configuration section, but not the object variable in script that represents the configuration section. In order for the change to appear in your scripts, you must call the WMI Refresh_
method on the object variable after you make the change. This will update the object variable with the latest data from the configuration store.
' ----------------------------------------------------------
' The first example adds a handler to the <handlers> section.
' ----------------------------------------------------------
' 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 handler names.
WScript.Echo "---[Old Handler List]---"
Call DisplayHandlers
' Create a new handler.
Set oHandler = oWebAdmin.Get("HandlerAction").SpawnInstance_
oHandler.Name = "NewHandler"
oHandler.Path="*.stm"
oHandler.Verb="GET,POST"
oHandler.Modules="ServerSideIncludeModule"
' Add the handler to the <handlers> section.
oHandlersSection.Add "Handlers", oHandler
' Call the WMI Refresh_ method to update the oHandlersSection object.
oHandlersSection.Refresh_
' Display the new handler names.
WScript.Echo "---[New Handler List]---"
Call DisplayHandlers
' ----------------------------------------------------------------
' The second example removes a handler by using the handler name.
' ----------------------------------------------------------------
' 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 handler names.
WScript.Echo "---[Old Handler List]---"
Call DisplayHandlers
' Remove the CGI-exe handler by name.
For Each oHandler In oHandlersSection.Handlers
If oHandler.Name = "CGI-exe" Then
oHandlersSection.Remove "Handlers", oHandler
End If
Next
' Call the WMI Refresh_ method to update the oHandlersSection object.
oHandlersSection.Refresh_
' Display the new list of handler names.
WScript.Echo "---[New Handler List]---"
Call DisplayHandlers
' This is the sub that displays the handler names.
Sub DisplayHandlers
WScript.Echo
For Each oHandler In oHandlersSection.Handlers
WScript.Echo "Handler Name: " & oHandler.Name
Next
End Sub
Inheritance Hierarchy
ConfigurationSectionWithCollection
HandlersSection
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
ConfigurationSectionWithCollection Class
HandlerAction Class