0

I have a couple of web applications deployed in an IIS Server (IIS 7.5 in W2k8 R2). In order to remove some HTTP Response Headers, I created a module (C# .dll), copied this .dll to each bin folder of each web application, and reference this module in the web.config of each one like below:

<system.webServer>
    <validation validateIntegratedModeConfiguration="false" />
    <modules>
      <add name="MyModule" type="MyNamespace.MyClass" />
    </modules>
</system.webServer>

From that point on, when I check the Module section of the web application in IIS, the reference is there and it works fine (the headers are not in the HTTP response).

PS.: I was not successful in using the GAC, anyways...

Here is what happens:

  • when I connect to https://example.com/myapp the header is not present in the response, as expected.
  • when I connect to https://example.com the header is present, as I didn´t want, but that is expected because I didn´t touch the Default Web Site at this point. Also, this Default Web Site is just an HTML redirection to one of the webapps.

The problem is, when it comes to the Default Web Site, I can´t find its web.config, nor do I find the place where I drop the .dll. Can anyone help?

Adriano_Pinaffo
  • 1,429
  • 4
  • 23
  • 46
  • "PS.: I was not successful in using the GAC, anyways...". As .NET Framework 2.x and 4.x have separate GAC locations, make sure your assembly is installed to both, and then IIS/ASP.NET can pick it up from there. – Lex Li Feb 07 '19 at 15:18
  • In fact I saw there are two folder structure inside C:\Windows\Microsoft.NET\Framework64, that is subfolders v2.0.50727 and v4.0.30319, but when I add the assembly to GAC using gacutil, I didn´t see a way to reference which .NET Framework would be this GAC repository... any idea how to do that? – Adriano_Pinaffo Feb 07 '19 at 16:25

1 Answers1

0

IIS has a global machine-level configuration file. All web.config files are essentially inheriting from that one. It works something like this (source):

enter image description here

You could simply add your module into the machine.config file and it will automatically be added to all sites. See this question to locate that file.

DavidG
  • 113,891
  • 12
  • 217
  • 223
  • I understand the C:\Windows\Microsoft.NET\Framework64\\Config should be the place to add that module (either inside machine.config or web.config), but 1) they seem to have different structures, as I don´t find a tag inside the . So, I´m not sure where to place this information and 2) there is no bin directory for me to drop the dll, like in the web apps, so I don´t know where the dll should be. Any ideas? – Adriano_Pinaffo Feb 07 '19 at 16:34