Modules <modules>


The <modules> element specifies the features that are available in IIS Manager when a user is connected to a site or an application. The <modules>element works with the <moduleProviders> element in the following way:

  • The <moduleProviders> element specifies the list of module providers for IIS Manager.
  • The <modules> element specifies the list of modules that will appear as features when a user connects to a site or an application to IIS Manager.

You can configure which modules will be available for individual Web sites using <location> tags, so that each Web site or application can be customized to suit your needs. For example, you could configure the site-level management for a Web site to allow only a small subset of features, and configure a child application for a broader set of features.

Note: This collection of modules is specific to IIS Manager and should not be confused with the <system.webServer modules> collection, which defines modules that affect HTTP request processing.

Note: The settings in the <modules> element can only be configured in the Administration.config file.


Version Notes
IIS 10.0 The <modules> element was not modified in IIS 10.0.
IIS 8.5 The <modules> element was not modified in IIS 8.5.
IIS 8.0 The <modules> element was not modified in IIS 8.0.
IIS 7.5 The <modules> element was not modified in IIS 7.5.
IIS 7.0 The <modules> element was introduced in IIS 7.0.
IIS 6.0 N/A


The <modules> element is included in the default installation of IIS 7.

How To

There is no user interface for adding modules to the <modules> element for IIS 7. For examples of how to add modules to the <modules> element programmatically, see the Code Samples section of this document.




Child Elements

Attribute Description
add Optional element.

Adds a module to the collection of modules for IIS Manager.

clear Optional element.

Removes all references to modules from the parent modules collection.

remove Optional element.

Removes a reference to a module from the collection of modules for IIS Manager.

Configuration Sample

The following sample configuration excerpt from the Administration.config file adds a managed module provider named ContosoProvider to the end of the <modules> collection.

Note: This sample configuration excerpt has been shortened for easier reading.

<location path=".">
      <add name="Modules" />
      <add name="Handlers" />

      . . .
      . . .
      . . .

      <add name="ContosoProvider" />

The following sample configuration excerpt from the Administration.config file specifies custom <modules> elements for the Default Web Site and a child application by defining unique <location> elements that clear the default module lists and define the specific modules that will be respectively enabled for each location. When a remote administration connects to either location, IIS Manager will only display those features that are represented by the modules that are listed in each <location> element.

<location path="Default Web Site">
      <clear />
      <add name="DefaultDocument" />
      <add name="DirectoryBrowse" />

<location path="Default Web Site/ContosoApplication">
      <clear />
      <add name="DefaultDocument" />
      <add name="DirectoryBrowse" />
      <add name="Handlers" />

Sample Code

The following code examples enable a managed module provider named ContosoProvider to the global location level in the Administration.config file.


Note: You cannot configure <modules> settings using AppCmd.exe.


using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
   private static void Main()
      using (ServerManager serverManager = new ServerManager())
         Configuration config = serverManager.GetAdministrationConfiguration();
         ConfigurationSection modulesSection = config.GetSection("modules");

         ConfigurationElementCollection modulesCollection = modulesSection.GetCollection();
         ConfigurationElement addElement = modulesCollection.CreateElement("add");
         addElement["name"] = @"ContosoProvider";



Imports System
Imports System.Text
Imports Microsoft.Web.Administration

Module Sample

   Sub Main()
      Dim serverManager As ServerManager = New ServerManager
      Dim config As Configuration = serverManager.GetAdministrationConfiguration
      Dim modulesSection As ConfigurationSection = config.GetSection("modules")

      Dim modulesCollection As ConfigurationElementCollection = modulesSection.GetCollection
      Dim addElement As ConfigurationElement = modulesCollection.CreateElement("add")
      addElement("name") = "ContosoProvider"

   End Sub

End Module


var adminManager = new ActiveXObject("Microsoft.ApplicationHost.WritableAdminManager"); 
adminManager.CommitPath = "MACHINE/WEBROOT"; 
adminManager.SetMetadata("pathMapper", "AdministrationConfig");
var modulesSection = adminManager.GetAdminSection("modules", "MACHINE/WEBROOT"); 

var modulesCollection = modulesSection.Collection;
var addElement = modulesCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "ContosoProvider";



Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT"
adminManager.SetMetadata "pathMapper", "AdministrationConfig"
Set modulesSection = adminManager.GetAdminSection("modules", "MACHINE/WEBROOT")

Set modulesCollection = modulesSection.Collection
Set addElement = modulesCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "ContosoProvider"

Deprecated Elements