Module Providers <moduleProviders>
The <moduleProviders>
element specifies 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. The <moduleProviders>
element works in relation with the <modules>
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 by using IIS Manager.
Note
The settings in the <moduleProviders>
element can only be configured in the Administration.config file.
Version | Notes |
---|---|
IIS 10.0 | The <moduleProviders> element was not modified in IIS 10.0. |
IIS 8.5 | The <moduleProviders> element was not modified in IIS 8.5. |
IIS 8.0 | The <moduleProviders> element was not modified in IIS 8.0. |
IIS 7.5 | The <moduleProviders> element was not modified in IIS 7.5. |
IIS 7.0 | The <moduleProviders> element was introduced in IIS 7.0. |
IIS 6.0 | N/A |
The <moduleProviders>
element is included in the default installation of IIS 7.
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.
None.
Element | Description |
---|---|
add |
Optional element. Adds a module to the collection of module providers for IIS Manager. |
clear |
Optional element. Removes all references to modules from the module providers collection. |
remove |
Optional element. Removes a reference to a module from the collection of module providers for IIS Manager. |
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>
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.
Note
You cannot configure <moduleProviders>
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 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();
}
}
}
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
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();
Set adminManager = WScript.CreateObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT"
adminManager.SetMetadata "pathMapper", "AdministrationConfig"
Set modulesSection = adminManager.GetAdminSection("modules", "MACHINE/WEBROOT")
Set moduleProvidersCollection = modulesSection.Collection
Set 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()