title: How to register an HttpModule suitable for VS2012 Cassini and IIS7?
body: <p>i have a simple <code>IHttpModule</code>:</p>
  
  <pre><code>using System;
  using System.Web;
  
  namespace DummyPlaceholder
  {
      class PerformanceHttpModule : IHttpModule
      {
          public void Init(HttpApplication application)
          {
          }
  
          public void Dispose()
          {
          }
      }
  }
  </code></pre>
  
  <p>And you register <strong>HttpModules</strong> inside <code>web.config</code>:</p>
  
  <pre><code>&lt;configuration&gt;
     &lt;system.web&gt;
        &lt;httpModules&gt;
           &lt;add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/&gt;
        &lt;/httpModules&gt;
     &lt;/system.web&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>When i was developing, and testing locally inside my Visual Studio 2012 integrated ("Cassini") web-server, everything worked great. </p>
  
  <p>When it came time to deploy to a live IIS7 web-server, the server would <a href="https://stackoverflow.com/questions/573325/500-internal-server-error-when-adding-httpmodule-in-my-website">give a <strong>500 Internal Server Error</strong>, and absolutely no information about the cause anywhere.</a></p>
  
  <p>The issue is that IIS7 changed how you register <strong>HttpModules</strong>, you no longer use <code>system.web</code>, instead you must now use <code>system.webServer</code>:</p>
  
  <pre><code>&lt;configuration&gt;
     &lt;system.webServer&gt;
        &lt;modules&gt;
           &lt;add name="PerformanceHttpModule" type="DummyPlaceholder.PerformanceHttpModule"/&gt;
        &lt;/modules&gt;
     &lt;/system.webServer&gt;
  &lt;/configuration&gt;
  </code></pre>
  
  <p>And now that works on IIS, but doesn't work inside Visual Studio 2012.</p>
  
  <p>What i need is a solution that works in both, without having to modify the <code>web.config</code> file when it is being published.</p>
  
  <p>The issue is that IIS7 and newer, have a new <strong><em>"Integrated"</em></strong> mode. The alternative mode is the behavior that IIS6 had, called <strong><em>"Classic"</em></strong> mode.</p>
  
  <p>Obviously i need to put the Visual Studio integrated web-server into <strong><em>"Integrated"</em></strong> mode, so that it look at:</p>
  
  <pre><code>configuration/webServer/modules
  </code></pre>
  
  <p>for modules.</p>
  
  <p>How do i do that?</p>
  
  <h1>Bonus Reading</h1>
  
  <ul>
  <li><a href="https://stackoverflow.com/questions/573325/500-internal-server-error-when-adding-httpmodule-in-my-website">&quot;500 Internal Server Error&quot; when adding HttpModule in my Website?</a></li>
  <li><a href="https://stackoverflow.com/questions/14492067/not-understanding-iis-classic-and-integrated-mode">Not understanding IIS Classic and Integrated Mode?</a></li>
  <li><a href="https://stackoverflow.com/questions/3111676/debugging-with-vs-2010-in-iis-7-classic-pipeline">Debugging with VS 2010 in IIS 7 classic pipeline</a></li>
  <li><a href="https://stackoverflow.com/questions/7621265/http-handlers-in-iis6-or-iis7-classic-mode">HTTP handlers in IIS6 or IIS7 classic mode</a></li>
  </ul>