Httpmodule still executed even if remove using <remove> config entry

Discussion in 'ASP .Net' started by Simon-Pierre Jarry, Aug 8, 2005.

  1. Hi,

    I created a custom HttpModule for managing the security of my
    application. in "Init" sub, I regsiter the events doing that :

    Public Sub Init(ByVal context As System.Web.HttpApplication) Implements
    IHttpModule.Init

    httpApp = context

    AddHandler httpApp.AuthenticateRequest, AddressOf
    OnAuthenticateRequest
    AddHandler httpApp.AcquireRequestState, AddressOf
    OnAcquireRequestState

    End Sub

    I register the httpModule in the web.config at the root of my
    application doing this :

    <httpModules>
    <add
    type="Russell.WebBackbone.Security.AppAuthenticationModule,Russell.WebBackbone.Security"
    name="AuthenticationModule" /> </httpModules>

    I want the httpModule not to execute on a subfolder called "Public".
    In the web.config file of my application at he root, I added this code
    :

    <location path="Public">
    <system.web>
    <authorization>
    <allow users="*" /> <!-- Allow all users -->
    </authorization>
    <httpModules>
    <remove name="AuthenticationModule" />
    </httpModules>
    </system.web>
    </location>

    Problem :
    The code of the Sub that handle the 2 events register earlier is
    still executed, event I asked the HttpModule to be removed on this
    folder ?

    Clue or hints ? : I noted that, when debugging, the
    context.HttpModules collection object at runtime still contains this
    "AuthenticationModule"... and should not !! I verified a few time and
    the name used to "ADD" the httpModule is the same then the name used to
    remove.

    Any idea ??

    I read somewhere that because the httpApplication object is "global"
    so, event if the httpModule is removed, the event handlers are still
    attached, so will be executed. Is it true ? If yes, any suggestion to
    detach those at a correct time ?


    Thanks a lot for your help !

    Simon-Pierre
    Simon-Pierre Jarry, Aug 8, 2005
    #1
    1. Advertising

  2. Simon-Pierre  Jarry

    Brock Allen Guest

    Modules can only be configured in the root web.config in the app.

    -Brock
    DevelopMentor
    http://staff.develop.com/ballen



    > Hi,
    >
    > I created a custom HttpModule for managing the security of my
    > application. in "Init" sub, I regsiter the events doing that :
    >
    > Public Sub Init(ByVal context As System.Web.HttpApplication)
    > Implements IHttpModule.Init
    >
    > httpApp = context
    >
    > AddHandler httpApp.AuthenticateRequest, AddressOf
    > OnAuthenticateRequest
    > AddHandler httpApp.AcquireRequestState, AddressOf
    > OnAcquireRequestState
    > End Sub
    >
    > I register the httpModule in the web.config at the root of my
    > application doing this :
    >
    > <httpModules>
    > <add
    > type="Russell.WebBackbone.Security.AppAuthenticationModule,Russell.Web
    > Backbone.Security"
    > name="AuthenticationModule" /> </httpModules>
    > I want the httpModule not to execute on a subfolder called "Public".
    > In the web.config file of my application at he root, I added this code
    > :
    >
    > <location path="Public">
    > <system.web>
    > <authorization>
    > <allow users="*" /> <!-- Allow all users -->
    > </authorization>
    > <httpModules>
    > <remove name="AuthenticationModule" />
    > </httpModules>
    > </system.web>
    > </location>
    >
    > Problem :
    > The code of the Sub that handle the 2 events register earlier is
    > still executed, event I asked the HttpModule to be removed on this
    > folder ?
    >
    > Clue or hints ? : I noted that, when debugging, the
    > context.HttpModules collection object at runtime still contains this
    > "AuthenticationModule"... and should not !! I verified a few time and
    > the name used to "ADD" the httpModule is the same then the name used
    > to remove.
    >
    > Any idea ??
    >
    > I read somewhere that because the httpApplication object is "global"
    > so, event if the httpModule is removed, the event handlers are still
    > attached, so will be executed. Is it true ? If yes, any suggestion to
    > detach those at a correct time ?
    >
    > Thanks a lot for your help !
    >
    > Simon-Pierre
    >
    Brock Allen, Aug 8, 2005
    #2
    1. Advertising

  3. Simon-Pierre  Jarry

    Henrik Guest

    I haven't tried to use HttpModules so can't really help you, but I DO read
    this newsgroup once in while, and I seem to remember reading something about
    this kind of problem way back.

    Since I haven't doen anything like this myself, I didn't check the
    particulars all that close, but I managed to find the conversion from that
    post (was in february 2005) here:

    http://www.msusenet.com/archive/index.php/t-1555956.html

    Hope this helps



    "Simon-Pierre Jarry" <> wrote in message
    news:...
    > Hi,
    >
    > I created a custom HttpModule for managing the security of my
    > application. in "Init" sub, I regsiter the events doing that :
    >
    > Public Sub Init(ByVal context As System.Web.HttpApplication) Implements
    > IHttpModule.Init
    >
    > httpApp = context
    >
    > AddHandler httpApp.AuthenticateRequest, AddressOf
    > OnAuthenticateRequest
    > AddHandler httpApp.AcquireRequestState, AddressOf
    > OnAcquireRequestState
    >
    > End Sub
    >
    > I register the httpModule in the web.config at the root of my
    > application doing this :
    >
    > <httpModules>
    > <add
    > type="Russell.WebBackbone.Security.AppAuthenticationModule,Russell.WebBackbone.Security"
    > name="AuthenticationModule" /> </httpModules>
    >
    > I want the httpModule not to execute on a subfolder called "Public".
    > In the web.config file of my application at he root, I added this code
    > :
    >
    > <location path="Public">
    > <system.web>
    > <authorization>
    > <allow users="*" /> <!-- Allow all users -->
    > </authorization>
    > <httpModules>
    > <remove name="AuthenticationModule" />
    > </httpModules>
    > </system.web>
    > </location>
    >
    > Problem :
    > The code of the Sub that handle the 2 events register earlier is
    > still executed, event I asked the HttpModule to be removed on this
    > folder ?
    >
    > Clue or hints ? : I noted that, when debugging, the
    > context.HttpModules collection object at runtime still contains this
    > "AuthenticationModule"... and should not !! I verified a few time and
    > the name used to "ADD" the httpModule is the same then the name used to
    > remove.
    >
    > Any idea ??
    >
    > I read somewhere that because the httpApplication object is "global"
    > so, event if the httpModule is removed, the event handlers are still
    > attached, so will be executed. Is it true ? If yes, any suggestion to
    > detach those at a correct time ?
    >
    >
    > Thanks a lot for your help !
    >
    > Simon-Pierre
    >
    Henrik, Aug 10, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Andy Green
    Replies:
    3
    Views:
    527
    Alvin Bruney
    Jan 10, 2004
  2. Umut Tezduyar
    Replies:
    4
    Views:
    3,311
    Ravi Ambros Wallau
    Feb 15, 2006
  3. Stan Goodman

    Even older fart, even newer newbie

    Stan Goodman, Jul 3, 2003, in forum: Java
    Replies:
    11
    Views:
    681
    Stan Goodman
    Jul 4, 2003
  4. Sunfire
    Replies:
    1
    Views:
    473
    Roland Dick
    Nov 10, 2007
  5. Hendrik Maryns
    Replies:
    4
    Views:
    761
    Hendrik Maryns
    Jun 10, 2008
Loading...

Share This Page