How to hook httpmodule and page event together?

Discussion in 'ASP .Net' started by =?Utf-8?B?d2FsdGVy?=, Mar 30, 2006.

  1. Hi there , for sure httpmodule can be hooked up with HttpApplication event.
    But I'm wondering if it's poissible to trigger a httpModule in the page event
    ,like Page.Init().

    Since request handler will be different among http/aspx, I hardly see it's
    possible. But may be someone knows. Reason I want to do this is because I
    like the plugin model provided by asp.net framework, but this time is just
    for page. If I can hook httpmodule and page event together, then I can make
    the page become plugable.

    Appreciate any inspiriting thought.

    Walter
    =?Utf-8?B?d2FsdGVy?=, Mar 30, 2006
    #1
    1. Advertising

  2. =?Utf-8?B?d2FsdGVy?=

    Bruno Piovan Guest

    Walter,
    take a look at this code I wrote...
    it will handle the PageInit event for all pages.....

    I hope it helps..

    Bruno


    Public Class MyModule

    Implements IHttpModule

    Public Sub Dispose() Implements System.Web.IHttpModule.Dispose

    End Sub

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

    AddHandler context.PreRequestHandlerExecute, AddressOf
    PreRequestHandlerExecute

    End Sub

    Sub PreRequestHandlerExecute(ByVal sender As Object, ByVal e As
    System.EventArgs)

    AddHandler CType(CType(sender, HttpApplication).Context.CurrentHandler,
    Page).Init, AddressOf PageInit

    End Sub

    Private Sub PageInit(ByVal sender As Object, ByVal e As System.EventArgs)

    Dim p As Page = CType(sender, Page)

    p.Response.Write("Hello")

    End Sub

    End Class




    "walter" <> wrote in message
    news:...
    > Hi there , for sure httpmodule can be hooked up with HttpApplication
    > event.
    > But I'm wondering if it's poissible to trigger a httpModule in the page
    > event
    > ,like Page.Init().
    >
    > Since request handler will be different among http/aspx, I hardly see it's
    > possible. But may be someone knows. Reason I want to do this is because I
    > like the plugin model provided by asp.net framework, but this time is just
    > for page. If I can hook httpmodule and page event together, then I can
    > make
    > the page become plugable.
    >
    > Appreciate any inspiriting thought.
    >
    > Walter
    >
    Bruno Piovan, Mar 30, 2006
    #2
    1. Advertising

  3. Hi Bruno,you answer is awesome. Thanks

    "Bruno Piovan" wrote:

    > Walter,
    > take a look at this code I wrote...
    > it will handle the PageInit event for all pages.....
    >
    > I hope it helps..
    >
    > Bruno
    >
    >
    > Public Class MyModule
    >
    > Implements IHttpModule
    >
    > Public Sub Dispose() Implements System.Web.IHttpModule.Dispose
    >
    > End Sub
    >
    > Public Sub Init(ByVal context As System.Web.HttpApplication) Implements
    > System.Web.IHttpModule.Init
    >
    > AddHandler context.PreRequestHandlerExecute, AddressOf
    > PreRequestHandlerExecute
    >
    > End Sub
    >
    > Sub PreRequestHandlerExecute(ByVal sender As Object, ByVal e As
    > System.EventArgs)
    >
    > AddHandler CType(CType(sender, HttpApplication).Context.CurrentHandler,
    > Page).Init, AddressOf PageInit
    >
    > End Sub
    >
    > Private Sub PageInit(ByVal sender As Object, ByVal e As System.EventArgs)
    >
    > Dim p As Page = CType(sender, Page)
    >
    > p.Response.Write("Hello")
    >
    > End Sub
    >
    > End Class
    >
    >
    >
    >
    > "walter" <> wrote in message
    > news:...
    > > Hi there , for sure httpmodule can be hooked up with HttpApplication
    > > event.
    > > But I'm wondering if it's poissible to trigger a httpModule in the page
    > > event
    > > ,like Page.Init().
    > >
    > > Since request handler will be different among http/aspx, I hardly see it's
    > > possible. But may be someone knows. Reason I want to do this is because I
    > > like the plugin model provided by asp.net framework, but this time is just
    > > for page. If I can hook httpmodule and page event together, then I can
    > > make
    > > the page become plugable.
    > >
    > > Appreciate any inspiriting thought.
    > >
    > > Walter
    > >

    >
    >
    >
    =?Utf-8?B?d2FsdGVy?=, Mar 31, 2006
    #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. djc
    Replies:
    7
    Views:
    455
  2. Robert Rolls

    HttpModule - OnAuthenticate event

    Robert Rolls, Jun 21, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    583
    Robert Rolls
    Jun 21, 2005
  3. Daniel Bickett
    Replies:
    2
    Views:
    369
    David Bolen
    Dec 30, 2004
  4. Lit
    Replies:
    5
    Views:
    866
    =?Utf-8?B?QnJhdWxpbyBEaWV6?=
    Aug 23, 2007
  5. Lit

    Page Events hook via designer

    Lit, Aug 23, 2007, in forum: ASP .Net
    Replies:
    1
    Views:
    366
    Mark Fitzpatrick
    Aug 23, 2007
Loading...

Share This Page