Interesting and annoying behaviour of Asp.Net with respect to HttpModules; the httpModules element in a web.config in a subdirectory, (note: not a seperate application) are ignored. No warning, no error, no nothing, just ignored.
After I spend the better part of yesterday afternoon working on this problem and google wasn’t very helpfull, I hope this will be helpfull to someone.
Proof of concept:

Layout of the project, notice the second web.config in the subdirectory.
HttpModules element in the root web.config:
<httpModules>
<add name="FirstHttpModule" type="httpModule.HttpModules.FirstHttpModule, httpModule" />
httpModules>
Interesting part of the FirstHttpModule class
private void context_BeginRequest(object sender, EventArgs e) {
HttpApplication source = sender as HttpApplication;
if( source != null ){
source.Context.Response.Write( "Hello from FirstHttpModule. " );
}
}
HttpModules element in the subdirectory web.config:
<httpModules>
<clear />
<add name="SecondHttpModule" type="httpModule.HttpModules.SecondHttpModule, httpModule" />
httpModules>
Interesting part of the SecondHttpModule class:
private
void context_BeginRequest(object sender, EventArgs e) {
private void context_BeginRequest(object sender, EventArgs e) {
HttpApplication source = sender as HttpApplication;
if( source != null ){
source.Context.Response.Write( "Hello from SecondHttpModule. " );
}
}
Result of a request to webform1.aspx in the root:

Result of a request to webform1.aspx in the subdirectory:

Source for the proof of concept:
httpModule.zip (17.17 KB)