473,503 Members | 1,635 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to hook httpmodule and page event together?

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

Mar 30 '06 #1
2 2599
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" <ww*@morneausobeco.com> wrote in message
news:8F**********************************@microsof t.com...
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

Mar 30 '06 #2
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" <ww*@morneausobeco.com> wrote in message
news:8F**********************************@microsof t.com...
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


Mar 31 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2187
by: Samuel | last post by:
I wrote a very simple httpmodule and tried to compile it with no success. This is my code: ============== Imports System Imports System.Web Imports Microsoft.VisualBasic NameSpace...
2
1640
by: moid | last post by:
i need help so that i can initialize page thorugh http module or handler i know it is possible through handler using ProcessRequest but im aint configure the things out. i need some...
3
3737
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
10
1871
by: Girish | last post by:
Ok, Ive been thinking about this problem for a while. I have 30 odd aspx pages (already built) on my website that I need to have some validation occur before the page should load. The validation...
4
6183
by: | last post by:
I have earlier used an HttpModule that did URL rewrites on the BeginRequest event. Now I am trying to use the same module in a different application on a new and upgraded machine (winxp sp2). ...
7
4115
by: Shapiro | last post by:
I have a scenario where I log a resquest to a database table and update the request with a corresponding response including the response time. I am using an HttpModule to do this. My challenge...
3
2110
by: MWells | last post by:
I'm having an issue getting my HttpHandlers and HttpModules to play together nicely. My HttpHandlers take special document types (defined by extension) and process them specially. I might have...
2
2126
by: Simon-Pierre Jarry | last post by:
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)...
3
2234
by: Dan Sikorsky | last post by:
I use an HttpModule that handles unhandled exceptions from an .aspx.cs page by logging to a text file, logging to the event viewer's app log, and sending out an email to the website developer and...
0
7202
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7332
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6991
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4673
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3167
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3154
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1512
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
736
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
382
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.