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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon-Pierre  Jarry

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

    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.Http Application) Implements
    IHttpModule.Ini t

    httpApp = context

    AddHandler httpApp.Authent icateRequest, AddressOf
    OnAuthenticateR equest
    AddHandler httpApp.Acquire RequestState, AddressOf
    OnAcquireReques tState

    End Sub

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

    <httpModules>
    <add
    type="Russell.W ebBackbone.Secu rity.AppAuthent icationModule,R ussell.WebBackb one.Security"
    name="Authentic ationModule" /> </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>
    <authorizatio n>
    <allow users="*" /> <!-- Allow all users -->
    </authorization>
    <httpModules>
    <remove name="Authentic ationModule" />
    </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.HttpMod ules collection object at runtime still contains this
    "Authentication Module"... 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

    #2
    Re: Httpmodule still executed even if remove using &lt;remove&g t; config entry

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

    -Brock
    DevelopMentor



    [color=blue]
    > 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.Http Application)
    > Implements IHttpModule.Ini t
    >
    > httpApp = context
    >
    > AddHandler httpApp.Authent icateRequest, AddressOf
    > OnAuthenticateR equest
    > AddHandler httpApp.Acquire RequestState, AddressOf
    > OnAcquireReques tState
    > End Sub
    >
    > I register the httpModule in the web.config at the root of my
    > application doing this :
    >
    > <httpModules>
    > <add
    > type="Russell.W ebBackbone.Secu rity.AppAuthent icationModule,R ussell.Web
    > Backbone.Securi ty"
    > name="Authentic ationModule" /> </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>
    > <authorizatio n>
    > <allow users="*" /> <!-- Allow all users -->
    > </authorization>
    > <httpModules>
    > <remove name="Authentic ationModule" />
    > </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.HttpMod ules collection object at runtime still contains this
    > "Authentication Module"... 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
    >[/color]



    Comment

    • Henrik

      #3
      Re: Httpmodule still executed even if remove using &lt;remove&g t; config entry

      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:



      Hope this helps



      "Simon-Pierre Jarry" <spjarry@gmail. com> wrote in message
      news:1123527844 .345415.314080@ g14g2000cwa.goo glegroups.com.. .[color=blue]
      > 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.Http Application) Implements
      > IHttpModule.Ini t
      >
      > httpApp = context
      >
      > AddHandler httpApp.Authent icateRequest, AddressOf
      > OnAuthenticateR equest
      > AddHandler httpApp.Acquire RequestState, AddressOf
      > OnAcquireReques tState
      >
      > End Sub
      >
      > I register the httpModule in the web.config at the root of my
      > application doing this :
      >
      > <httpModules>
      > <add
      > type="Russell.W ebBackbone.Secu rity.AppAuthent icationModule,R ussell.WebBackb one.Security"
      > name="Authentic ationModule" /> </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>
      > <authorizatio n>
      > <allow users="*" /> <!-- Allow all users -->
      > </authorization>
      > <httpModules>
      > <remove name="Authentic ationModule" />
      > </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.HttpMod ules collection object at runtime still contains this
      > "Authentication Module"... 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
      >[/color]


      Comment

      Working...