Standing on the shoulders of giants. RSS 2.0
# Thursday, June 23, 2005

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:

Solution

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:

FirstModule

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

SecondModule

 

Source for the proof of concept: httpModule.zip (17.17 KB)
Thursday, June 23, 2005 6:53:41 AM (Pacific Daylight Time, UTC-07:00)  #    Comments [1] - Trackback
ASP.NET
Thursday, January 12, 2006 4:42:56 PM (Pacific Standard Time, UTC-08:00)
Damn, I have also encountered this issue and lost two hours debugging it.
I have filed a bug: http://lab.msdn.microsoft.com/productfeedback/viewfeedback.aspx?feedbackid=91763c85-649a-4bcd-8fbe-11f4c1d14fc5
Comments are closed.
Ads
About
© Copyright 2014
Paul van Brenk
Sign In
newtelligence dasBlog 2.3.12105.0
All Content © 2014, Paul van Brenk
DasBlog theme 'Business' created by Christoph De Baene (delarou)