Adding Modules <add>


The <add> element of the <modules> element adds a module to the collection of feature modules that are available in IIS Manager when a user is connected to a site or an application.

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 8.5 The <add> element was not modified in IIS 8.5.
IIS 8.0 The <add> element was not modified in IIS 8.0.
IIS 7.5 The <add> element was not modified in IIS 7.5.
IIS 7.0 The <add> element of the <modules> element was introduced in IIS 7.0.
IIS 6.0 N/A


The <add> element of 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.



Attribute Description
name Required string attribute.

Specifies the unique name of a managed module on the Web server.

Child Elements


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