Global Modules <globalModules>

Overview

The <globalModules> element defines the global-level modules installed on an IIS 7 server. The <globalModules> element is only available at the server level, so when you install modules, IIS only updates the ApplicationHost.config file. You must be an administrator on the server to install native modules.

IIS 7 implements most of its request processing through native modules. When you install an IIS 7 role service or feature using the Service Manager, the IIS installer adds an entry to the <globalModules> element for that module. For example, when you install the Basic authentication role service on your IIS 7 server, the installer adds a BasicAuthenticationModule entry to the <globalModules> element.

When you install a third-party module, you must add an entry to the <globalModules> element for that module. You can do this by using the IIS Manager, by manually editing the ApplicationHost.config file, or by using the AppCmd.exe command-line tool.

To enable a module in an application, you must edit the application's <module> element.

Compatibility

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

Setup

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

How To

How to install a native module

  1. Open Internet Information Services (IIS) Manager:

    • If you are using Windows Server 2012 or Windows Server 2012 R2:

      • On the taskbar, click Server Manager, click Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows 8 or Windows 8.1:

      • Hold down the Windows key, press the letter X, and then click Control Panel.
      • Click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
    • If you are using Windows Server 2008 or Windows Server 2008 R2:

      • On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows Vista or Windows 7:

      • On the taskbar, click Start, and then click Control Panel.
      • Double-click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
  2. In the Connections pane, click the server connection to which you want to add the native module.

  3. On the server Home page, double-click Modules.
    Screenshot of five icons titled MIME Types, Modules, Output Caching, Server Certificates, and Worker Processes. The icon titled Modules is highlighted.

  4. In the Actions pane, click Configure Native Modules...

  5. In the Configure Native Modules dialog box, click Register...
    Screenshot of the Configure Native Modules dialog box.

  6. In the Register Native Module dialog box, in the Name box, type a name for the native module.

  7. In the Path box, type the file system path of the location of the .dll file or click the Browse button
    Screenshot of the Path box showing the file system path and the name of the location of the . d d l file.

  8. In the Configure Native Modules dialog box, select the option for the native module that you just registered, click OK, and then click OK again. This enables the native module to run and makes it available to sites and applications on your Web server.

    Note

    If you do not want to enable the native module to run, clear the option for the native module, and then click OK.

  9. Optionally, you can lock the native module if you do not want it to be overridden at lower levels in the configuration system. On the Modules page, select the module, and then click Lock in the Actions pane.

How to enable a native module

  1. Open Internet Information Services (IIS) Manager:

    • If you are using Windows Server 2012 or Windows Server 2012 R2:

      • On the taskbar, click Server Manager, click Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows 8 or Windows 8.1:

      • Hold down the Windows key, press the letter X, and then click Control Panel.
      • Click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
    • If you are using Windows Server 2008 or Windows Server 2008 R2:

      • On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
    • If you are using Windows Vista or Windows 7:

      • On the taskbar, click Start, and then click Control Panel.
      • Double-click Administrative Tools, and then double-click Internet Information Services (IIS) Manager.
  2. Navigate to the server, site, or application level that you want to manage.

  3. On the server, site, or application Home page, double-click Modules.

  4. In the Actions pane, click Configure Native Modules...

  5. In the Configure Native Modules dialog box, select the option for the native module that you want to enable, and then click OK.
    Screenshot of the Configure Native Modules dialog box. The registered module titled UriCacheModule is selected.

Configuration

The <globalModules> element contains a collection of <add> elements. Each element in the collection configures a global module for the server.

Attributes

None.

Child Elements

Element Description
add Optional element.

Adds a native module to the collection of global modules.
clear Optional element.

Removes all references to native modules from the global modules collection.
remove Optional element.

Removes a reference to a specific native module from the global modules collection.

Configuration Sample

The following example shows an IIS 7 <globalModules> section that contains entries for all modules included in the minimal installation of the Web server. It also includes an entry for the BasicAuthenticationModule and another for the ImageCopyrightModule third-party module.

<globalModules>
   <add name="UriCacheModule"
      image="%windir%\System32\inetsrv\cachuri.dll" />
   <add name="FileCacheModule"
      image="%windir%\System32\inetsrv\cachfile.dll" />
   <add name="TokenCacheModule"
      image="%windir%\System32\inetsrv\cachtokn.dll" />
   <add name="HttpCacheModule"
      image="%windir%\System32\inetsrv\cachhttp.dll" />
   <add name="StaticCompressionModule"
      image="%windir%\System32\inetsrv\compstat.dll" />
   <add name="DefaultDocumentModule"
      image="%windir%\System32\inetsrv\defdoc.dll" />
   <add name="DirectoryListingModule"
      image="%windir%\System32\inetsrv\dirlist.dll" />
   <add name="ProtocolSupportModule"
      image="%windir%\System32\inetsrv\protsup.dll" />
   <add name="StaticFileModule"
      image="%windir%\System32\inetsrv\static.dll" />
   <add name="AnonymousAuthenticationModule"
      image="%windir%\System32\inetsrv\authanon.dll" />
   <add name="RequestFilteringModule"
      image="%windir%\System32\inetsrv\modrqflt.dll" />
   <add name="CustomErrorModule"
      image="%windir%\System32\inetsrv\custerr.dll" />
   <add name="HttpLoggingModule"
      image="%windir%\System32\inetsrv\loghttp.dll" />
   <add name="RequestMonitorModule"
      image="%windir%\System32\inetsrv\iisreqs.dll" />
   <add name="BasicAuthenticationModule"
      image="%windir%\System32\inetsrv\authbas.dll" />
   <add name="ImageCopyrightModule"
      image="%windir%\System32\inetsrv\ImageCopyrightModule.dll" />
</globalModules>

Sample Code

The following examples install a native module named ImageCopyrightModule on IIS 7 and automatically enable it on the entire server.

AppCmd.exe

appcmd.exe install module /name:ImageCopyrightModule /image:%windir%\system32\inetsrv\imageCopyrightModule.dll

You can also use the following syntax:

appcmd.exe set config -section:system.webServer/globalModules /+"[name='ImageCopyrightModule',image='%windir%\system32\inetsrv\imageCopyrightModule.dll']" /commit:apphost

Note

You must be sure to set the commit parameter to apphost when you use AppCmd.exe to configure these settings. This commits the configuration settings to the appropriate location section in the ApplicationHost.config file.

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.GetApplicationHostConfiguration();
         ConfigurationSection globalModulesSection = config.GetSection("system.webServer/globalModules");
         ConfigurationElementCollection globalModulesCollection = globalModulesSection.GetCollection();
         ConfigurationElement addElement = globalModulesCollection.CreateElement("add");
         addElement["name"] = @"ImageCopyrightModule";
         addElement["image"] = @"%windir%\system32\inetsrv\imageCopyrightModule.dll";
         globalModulesCollection.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.GetApplicationHostConfiguration
      Dim globalModulesSection As ConfigurationSection = config.GetSection("system.webServer/globalModules")
      Dim globalModulesCollection As ConfigurationElementCollection = globalModulesSection.GetCollection
      Dim addElement As ConfigurationElement = globalModulesCollection.CreateElement("add")
      addElement("name") = "ImageCopyrightModule"
      addElement("image") = "%windir%\system32\inetsrv\imageCopyrightModule.dll"
      globalModulesCollection.Add(addElement)
      serverManager.CommitChanges()
   End Sub
End Module

JavaScript

var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";

var globalModulesSection = adminManager.GetAdminSection("system.webServer/globalModules", "MACHINE/WEBROOT/APPHOST");
var globalModulesCollection = globalModulesSection.Collection;

var addElement = globalModulesCollection.CreateNewElement("add");
addElement.Properties.Item("name").Value = "ImageCopyrightModule";
addElement.Properties.Item("image").Value = "%windir%\\system32\\inetsrv\\imageCopyrightModule.dll";
globalModulesCollection.AddElement(addElement);

adminManager.CommitChanges();

VBScript

Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"

Set globalModulesSection = adminManager.GetAdminSection("system.webServer/globalModules", "MACHINE/WEBROOT/APPHOST")
Set globalModulesCollection = globalModulesSection.Collection

Set addElement = globalModulesCollection.CreateNewElement("add")
addElement.Properties.Item("name").Value = "ImageCopyrightModule"
addElement.Properties.Item("image").Value = "%windir%\system32\inetsrv\imageCopyrightModule.dll"
globalModulesCollection.AddElement addElement

adminManager.CommitChanges()