How do I register a HttpModule in the machine.conf

2019-06-12 14:20发布

问题:

I'm trying to install a HttpModule on all sites on a server. It is already in the GAC and is working on sites if I individually add the proper configuration to each site's web.config file. When I move the configuration into the machine.config or the global web.config, the module disappears.

Right now, I have the config in the system.webserver/httpModules and the system.web/httpModules sections in both the 32 bit and 64 bit machine.config and global web.config - eight places total and none of them are working.

I've installed modules in the machine.config on IIS6 before and it is easy. Is there a trick for installing them in IIS7?

回答1:

Apparently, the machine.config is not responsible for defining the system.webServer section. In fact, it defines the section as

<section name="system.webServer" type="System.Configuration.IgnoreSection, System.Configuration, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a"/>

Note the type: System.Configuration.IgnoreSection.

The system.webServer section is defined in

%windir%\system32\inetsrv\config\applicationhost.config

Directly after the system.webserver section, there is

<location path="" overrideMode="Allow">
    <system.webServer>

    <modules>
        <!-- add the module here -->
        <add name="MyModule" type="MyNamespace.MyModule, MyAssmebly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdefhijklmnop"/>

    </modules>

    </system.webServer>

</location>