title: How do I deploy a managed HTTP Module Site Wide?
body: <p>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.</p>
  
  <p>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).</p>
  
  <p>Once installed I modify the <code>&lt;compilation&gt;</code> element of the web site's web.config file to reference the assembly, like so:</p>
  
  <pre><code>&lt;compilation debug="false"&gt;
      &lt;assemblies&gt;
          &lt;add assembly="Company.Product.Module, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxxxxx" /&gt;
      &lt;/assemblies&gt;
  &lt;/compilation&gt;
  </code></pre>
  
  <p>I also modified the <code>&lt;modules&gt;</code> element of the web site's web.config file.</p>
  
  <pre><code>&lt;system.webServer&gt;
      &lt;modules&gt;
          &lt;add name="MyModule" type="Company.Product.Module.MyModule" /&gt;
      &lt;/modules&gt;
  &lt;/system.webServer&gt;
  </code></pre>
  
  <p>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:</p>
  
  <blockquote>
    <p>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.</p>
  </blockquote>
  
  <p>There are two ways I know to get around this:</p>
  
  <p><strong>Option 1:</strong></p>
  
  <p>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.</p>
  
  <p><strong>Option 2:</strong></p>
  
  <p>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?</p>
  
  <p>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?</p>