title: Problems deploying a HttpModule in Asp.Net 4.0
body: <p>I want to do UrlRewriting. in order to do that I have written a HttpModule that runs upon the <code>AuthorizeRequest</code> event in the ASP.NET Http Modules chain (before the request is processed by the HttpHandler).</p>
  <h2>Context</h2>
  <p>I wrote an abstract class as a basic rewriter which implements the <code>IHttpModule</code> interface:</p>
  <pre><code>public abstract class BaseModuleRewriter : IHttpModule {
    public virtual void Init(HttpApplication app) {
      // WARNING! This does not work with Windows authentication!
      app.AuthorizeRequest += new ventHandler(this.BaseModuleRewriter_AuthorizeRequest);
    }
    public virtual void Dispose() { }
    protected virtual void BaseModuleRewriter_AuthorizeRequest(object sender, EventArgs e) {
      HttpApplication app = (HttpApplication)sender;
      this.Rewrite(app.Request.Path, app);
    }
    protected abstract void Rewrite(string requestedPath, HttpApplication app);
  }
  </code></pre>
  <p>The real implementation of the module is the following class:</p>
  <pre><code>public class ModuleRewriter : BaseModuleRewriter {
    protected override void Rewrite(string requestedPath, System.Web.HttpApplication app) {
      // Just dummy, if the module works, I should never get to any page other than homepage
      UrlRewritingUtils.RewriteUrl(app.Context, &quot;Default.aspx&quot;);
    }
  }
  </code></pre>
  <p>In my web.config I have the following:</p>
  <pre><code>&lt;configuration&gt;
    ...
    &lt;system.web&gt;
      &lt;httpModules&gt;
        &lt;add type=&quot;ModuleRewriter&quot; name=&quot;ModuleRewriter&quot;/&gt;
      &lt;/httpModules&gt;
    &lt;/system.web&gt;
    ...
  &lt;/configuration&gt;
  </code></pre>
  <p>Actually this is a simple implementation of Url-Rewriting from an article posted in MSDN Megazine. I just made it simpler, but the approach is that one.</p>
  <h2>The problem</h2>
  <p>It does not work! When I deploy the module like I told you and request a page, I can get to all my pages of my website, when, on the contrary, I should always be &quot;redirected&quot; to <code>Default.aspx</code>.</p>
  <p>What to do?</p>
  <h2>Additional info</h2>
  <p>First of all, one important information: My application pool is <em>Integrated Mode</em> targeting framework 4.0.</p>
  <p>My web site is not compiled. I mean that I do not precompile my web site but I put all my code in the <code>App_Code</code> directory and let ASP.NET compile it when pages are requested. A direct consequence is that all my assemblies are put in the <code>%sysroot%\Microsoft.NET\Framework\v4.0.30319\Temporary ASP.NET Files\...</code> directory.</p>
  <p>I read some stuff where modules are deployed in the web.config by specifying the assemply as well, something like:</p>
  <pre><code>&lt;configuration&gt;
    ...
    &lt;system.web&gt;
      &lt;httpModules&gt;
        &lt;add type=&quot;ModuleRewriter, ModuleRewriterAssembly&quot; name=&quot;ModuleRewriter&quot;/&gt;
      &lt;/httpModules&gt;
    &lt;/system.web&gt;
    ...
  &lt;/configuration&gt;
  </code></pre>
  <p>But, being my stuff not precompiled, but entirely managed by Asp.Net, I cannot specify a different assembly. Is it needed to solve this problem? If so, what to do?</p>
  <p>Thankyou</p>