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:
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. " ); }}
Interesting part of the SecondHttpModule class:
private
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 subdirectory: