<p>Is there a good way to exclude certain pages from using a HTTP module?</p>

<p>I have an application that uses a custom HTTP module to validate a session. The HTTPModule is set up like this in web config:</p>

<pre><code>&lt;system.web&gt;
  &lt;!-- ... --&gt;
  &lt;httpModules&gt;
    &lt;add name="SessionValidationModule"
       type="SessionValidationModule, SomeNamespace" /&gt;
  &lt;/httpModules&gt;
&lt;/system.web&gt;
</code></pre>

<p>To exclude the module from the page, I tried doing this (without success):</p>

<pre><code>&lt;location path="ToBeExcluded"&gt;
  &lt;system.web&gt;
    &lt;!-- ... --&gt;
    &lt;httpModules&gt;
      &lt;remove name="SessionValidationModule" /&gt;
    &lt;/httpModules&gt;
  &lt;/system.web&gt;
&lt;/location&gt;
</code></pre>

<p>Any thoughts?</p>

You could use an HTTPHandler instead of an HTTPModule.  Handlers let you specify a path when you declare them in Web.Config.
```
```
<add verb="*" path="/validate/*.aspx" type="Handler,Assembly"/>
```
```
If you must use an HTTPModule, you could just check the path of the request and if it's one to be excluded, bypass the validation.