在我的web应用程序,为什么不是我的machine.config中的HttpModule运行?我的、应用程序、不是、web

2023-09-04 06:15:24 作者:学不会、敷衍

我在.NET 3.5写了 HTTP模块,32位2003赢,IIS 6的工作太棒了。它的组件是在GAC和配置是在 machine.config的。一切多年来一直很大。

I wrote a HttpModule in .NET 3.5, 32 bit Win 2003, IIS 6 that worked great. Its assemblies were in the GAC and the config was in the machine.config. Everything has been great for years.

我只是把它全部转移到新的.NET 2-4,64位赢得2008 R2中,IIS 7.5的机器,并把同样的,旧的配置在 machine.config的。不幸的是,该模块不被列为那些网站上运行。当我把配置直接进入网站的web.config ,然后将其运行正常。 为什么我的应用程序继承从HTTP模块的 machine.config的

I just brought it all over to a new .NET 2-4, 64 bit Win 2008 R2, IIS 7.5 machine and put the same, old configuration in the machine.config. Unfortunately, the module isn't listed as those that are running on the site. When I put the configuration directly into a site's web.config, then it runs as expected. Why isn't my app inheriting the HttpModule from the machine.config?

这个配置不执行任何操作在machine.config,但按预期在web.config中。的

<system.webServer>
    <modules runAllManagedModulesForAllRequests="true">
        <add name="MyModule" type="MyModule, MyAssmebly, Version=1.0.0.0, Culture=neutral, PublicKeyToken=abcdefghijklmno" />
    </modules>
</system.webServer>

我把每一个可能的Machine.config文件中的配置无济于事:

I put the config in every possible machine.config file to no avail:

C:\ WINDOWS \ Microsoft.NET \ Framework64 \ v4.0.30319 \ Config中 C:\ WINDOWS \ Microsoft.NET \ Framework64 \ V2.0.50727 \ CONFIG C:\ WINDOWS \ Microsoft.NET \框架\ v4.0.30319 \ Config中 C:\ WINDOWS \ Microsoft.NET \框架\ V2.0.50727 \ CONFIG C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config C:\Windows\Microsoft.NET\Framework64\v2.0.50727\CONFIG C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG

配置的其他元素继承的web.config中:的System.Web \编译 system.serviceModel \绑定来命名一对夫妇。该模块采用的配置为 machine.config的 WCF。这似乎仅仅是 HTTP模块的心不是被继承。不,没有&LT;清/&GT; 的任何地方

Other elements of the configuration are inherited to the web.config: system.web\compilation and system.serviceModel\bindings to name a couple. The module uses WCF that is configured in machine.config. It appears to just be the HttpModule that isnt being inherited. No, there is no <clear/> anywhere.

推荐答案

显然, machine.config的不负责定义系统。 web服务器部分。事实上,它定义了部为

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>