0

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.

Community
  • 1
  • 1
Jeff
  • 13,943
  • 11
  • 55
  • 103
  • What is the mode of the application pool the site is sitting in? – Grant Thomas Oct 25 '11 at 15:17
  • Did you try to put it in the global `web.config`, instead of the `machine.config`? – Oded Oct 25 '11 at 15:18
  • Did you rebooted the server??? Normally it is not needed but if it is a test server worth retrying. – Aliostad Oct 25 '11 at 15:19
  • @Mr.Disappointment It is in integrated mode. – Jeff Oct 25 '11 at 15:27
  • @Aliostad I've rebooted IIS but not the whole machine. – Jeff Oct 25 '11 at 15:28
  • @Oded Yes, I tried previously and I just tried again, rebooting IIS after the attempt. No luck. – Jeff Oct 25 '11 at 15:32
  • @Jeff This is a long shot (it seems you're not getting errors, it's just not working), but since the configs are shared, can you try disabling validation by adding the following above your ``: `` – Grant Thomas Oct 25 '11 at 16:50
  • @Mr.Disappointment No luck with that :( – Jeff Oct 26 '11 at 13:11
  • @Jeff With the config files being shared, there _might_ have been a conflicting issue with validating the structure if _anything_ was using classic mode with others in integrated (producing errors, usually visible, hence my "long shot") - this essentially tells IIS that you know what is in the config _and_ that is it correct / required, skipping any distinct errors. – Grant Thomas Oct 26 '11 at 13:12

1 Answers1

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>
Jeff
  • 13,943
  • 11
  • 55
  • 103