如何在IIS 7的machine.config中注册HttpModule?

问题描述:

我正在尝试在服务器上的所有站点上安装HttpModule。如果我分别将正确的配置添加到每个站点的 web.config 文件中,它已经在GAC中并且可以在站点上运行。当我将配置移至 machine.config 或全局 web.config 时,该模块消失了。

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.

现在,我在 system.webserver / httpModules 中有配置32位和64位 machine.config 和全局 web.config 中的system.web / httpModules 部分code>-总共八个地方,没有一个在工作。

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.

我已经在 machine.config $中安装了模块IIS6上的c $ c>,这很容易。

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

显然, machine.config 不负责定义 system.webServer 部分。实际上,它将该节定义为

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"/>

请注意类型: System.Configuration.IgnoreSection

system.webServer 部分在

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

紧接 system.webserver 部分之后,有

<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>