I am developing a manged HTTP Module that will intercept requests to and response from IIS 7. The intercepted messages will be modified based on a set of business rules by a custom filter. The business rules will be stored in a configuration file.
The messages must be intercepted web site wide. This includes any applications or virtual directories that exist as children of the web site. My first attempt at this was to install the HTTP Module assembly in the bin directory of the desired web site.(e.g., C:\inetpub\wwwroot\bin for the Default Web Site).
Once installed I modify the <compilation>
element of the web site's web.config file to reference the assembly, like so:
<compilation debug="false">
<assemblies>
<add assembly="Company.Product.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" />
</assemblies>
</compilation>
I also modified the <modules>
element of the web site's web.config file.
<system.webServer>
<modules>
<add name="MyModule" type="Company.Product.Module.MyModule" />
</modules>
</system.webServer>
This works well for most content under the web site. However, if there is an application configured under the website (e.g., /wwwroot/MyApplication) I receive the following error when navigating to any resource under that web application:
Could not load file or assembly 'Company.Product.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx' or one of its dependencies. The system cannot find the file specified.
There are two ways I know to get around this:
Option 1:
Copy the HTTP Module assembly and all dependent assemblies to each application's bin directory. I believe that I would also need to duplicate the configuration information from the parent directory. This can become a management nightmare as more and more applications are added to the web site.
Option 2:
Install the HTTP Module assembly and all dependent assemblies in the GAC. This seems to work quite well and avoids a lot of management overhead, however, where does configuration information live? If in the web site's web.config file is this information inherited in all the child applications?
What is the recommend method for deploying a managed HTTP Module site wide? How should configuration be handled so that all configuration is in a central location?