问题
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.
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
?
This config does nothing in the machine.config, but works as expected in the 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>
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\Framework\v4.0.30319\Config
C:\Windows\Microsoft.NET\Framework\v2.0.50727\CONFIG
UPDATE
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.
回答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>
来源:https://stackoverflow.com/questions/7891521/why-isnt-my-machine-config-httpmodule-running-in-my-web-app