Adding Module Providers <add>

Overview

The <add> element of the <moduleProviders> element adds a module to the list of module providers for IIS Manager. Each module provider entry contains the managed-code registration information for a module, which enables the module as a feature in IIS Manager.

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

Compatibility

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 <moduleProviders> element was introduced in IIS 7.0.
IIS 6.0 N/A

Setup

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

How To

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

Configuration

Attributes

Attribute Description
name Required string attribute.

Specifies the unique name of a managed module on the Web server.
type Required string attribute.

Specifies the managed type of a managed module.

Child Elements

None.

Configuration Sample

The following sample configuration excerpt from the Administration.config file adds a managed module provider named ContosoProvider to the end of the <moduleProviders> collection. The name property defines the name ContosoProvider for the module, and the type property defines the managed type for the module.

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

<moduleProviders>
   <!-- Server Modules-->
   <add name="Modules"
      type="Microsoft.Web.Management.Iis.Modules.ModulesModuleProvider, Microsoft.Web.Management.Iis, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
   <add name="Handlers"
      type="Microsoft.Web.Management.Iis.Handlers.HandlersModuleProvider, Microsoft.Web.Management.Iis, Version=7.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />

      . . .
      . . .
      . . .

   <add name="ContosoProvider"
      type="Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=426f62526f636b73" />
</moduleProviders>

Sample Code

Note: The examples in this document illustrate using a managed-code assembly that has been stored in the .NET Global Assembly Cache (GAC). Before using the code in these examples to deploy your own assemblies, you need to retrieve the assembly information from the GAC. To do so, use the following steps:

  • In Windows Explorer, open your C:\Windows\assembly path, where C: is your operating system drive.
  • Locate your assembly.
  • Right-click the assembly and click Properties.
  • Copy the Culture value; for example: Neutral.
  • Copy the Version number; for example: 1.0.0.0.
  • Copy the Public Key Token value; for example: 426f62526f636b73.
  • Click Cancel.

The following code examples add a managed module provider named ContosoProvider to the Administration.config file. The name property defines the name ContosoProvider for the module, and the type property defines the managed type for the module.

AppCmd.exe

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

C#

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 moduleProvidersSection = config.GetSection("moduleProviders");

         ConfigurationElementCollection moduleProvidersCollection = moduleProvidersSection.GetCollection();
         ConfigurationElement addElement = moduleProvidersCollection.CreateElement("add");
         addElement["name"] = @"ContosoProvider";
         addElement["type"] = @"Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=426f62526f636b73";
         moduleProvidersCollection.Add(addElement);

         serverManager.CommitChanges();
      }
   }
}

VB.NET

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 moduleProvidersSection As ConfigurationSection = config.GetSection("moduleProviders")

      Dim moduleProvidersCollection As ConfigurationElementCollection = moduleProvidersSection.GetCollection
      Dim addElement As ConfigurationElement = moduleProvidersCollection.CreateElement("add")
      addElement("name") = "ContosoProvider"
      addElement("type") = "Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=426f62526f636b73"
      moduleProvidersCollection.Add(addElement)

      serverManager.CommitChanges()
   End Sub

End Module

JavaScript

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

var moduleProvidersCollection = moduleProvidersSection.Collection;
var addElement = moduleProvidersCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "ContosoProvider";
addElement.Properties.Item("type").Value = "Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=426f62526f636b73";
moduleProvidersCollection.AddElement(addElement);

adminManager.CommitChanges();

VBScript

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

var moduleProvidersCollection = moduleProvidersSection.Collection;
var addElement = moduleProvidersCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "ContosoProvider";
addElement.Properties.Item("type").Value = "Contoso.Provider, System.Web, Version=1.0.0.0, Culture=neutral, PublicKeyToken=426f62526f636b73";
moduleProvidersCollection.AddElement(addElement);

adminManager.CommitChanges();
Deprecated Elements