Search:
Namespaces
Discussions
.NET v1.1
Feedback
Request Handlers, Executing Handler AND Getting requested resource
Messages
Related Types
This message was discovered on
ASPFriends.com 'aspnghttphandlers' list
.
Responses highlighted in red are from those people who are likely to be able to contribute good, authoratitive information to this discussion. They include Microsoft employees, MVP's and others who IMHO contribute well to these kinds of discussions.
John Shipway
-- This message, which was originally sent to "aspngbeta", has been moved to "aspnghttphandlers" mailing list by the List Master --
Hello,
I thought of using Request Handlers to be able execute some
pre-processing code whenever a given page type is requested (ie .aspx).
It seems that if I implement a handler for all .aspx files in a web, the
handler will execute, but the requested .aspx will not. I am looking
for behaviour similar to an ISAPI filter, where both the filter and the
requested resource execute. Is there a config setting in the
<httphandlers> I need to flip to make this happen? Or is there another
asp.net component I need to use other than a handler? =20
Thanks,=20
John
Reply to this message...
Mitch Denny (VIP)
John,
You might want to consider implementing the
IHttpModule
interface. By implementing that interface, on one of
your objects you can do what you want. All you need to
do is implement the Init(
HttpApplication
context) method
and attach event handlers to the context object. See
the code below as an example (watch for wrapping):
using System;
using System.Web;
public class JohnShipwayHttpModule :
IHttpModule
{
public void Init(
HttpApplication
context) {
context.BeginRequest += new
EventHandler
(this.OnContextBeginRequest);
}
protected void OnContextBeginRequest(object sender,
EventArgs
e) {
// Do something you find interesting.
}
}
When this module is added to the mix, the *.aspx pages
will be processed as normal but your HttpModule will
be part of the transaction. To complete the circle,
check out the <httpModules></httpModules> section in
your Config.web file, or alternatively in the SDK
documentation. Give it a shot!
----------------------------------------
- Mitch Denny
-
http://www.warbyte.com
-
Click here to reveal e-mail address
- +61 (414) 610-141
-
[Original message clipped]
Reply to this message...
Mark M
Mitch,
I'm trying to create an HttpModule but I don't quite understand the details
of the Init method. I can't find this in the beta 2 help either. Do you know
what topic it is under?
Thanks,
M
[Original message clipped]
Reply to this message...
Mitch Denny (VIP)
Mark,
Talking about BETA 2 or the interim builds is a violation
of the NDA that you would have had to sign to get it. Regardless,
talking about
IHttpModule
is still BETA 1 domain, so I guess
its OK :)
Essentially, the ASP.NET calls the
IHttpModule
.Init() method
on your object passing it an instance of the
HttpApplication
class. What you do in the Init() method is then up to you,
but the normal routine is to attach a number of event handlers
to it. For example, your module could have an event handler
for the BeginRequest event. Those event handlers will then
be fired when a user connects.
I hope this makes sense. Where you looking for a code
sample or just a why is it so explaination?
----------------------------------------
- Mitch Denny
-
http://www.warbyte.com
-
Click here to reveal e-mail address
- +61 (414) 610-141
-
[Original message clipped]
Reply to this message...
Nse Ekong
I am also wondering about EventHandlers. How does one attach EventHandlers in VB? It seems that all the examples are in C#, but I need this task accomplished in VB.
--------------------------------
From: Nse Ekong
Reply to this message...
System.EventArgs
System.EventHandler
System.Web.HttpApplication
System.Web.IHttpModule
Ad
MBR BootFX
Best-of-breed application framework for .NET projects, developed by Matthew Baxter-Reynolds and MBR IT
Copyright © Matthew Baxter-Reynolds 2001-2008. '.NET 247 Software Development Services' is a trading style of MBR IT Solutions Ltd.
Contact Us
-
Terms of Use
-
Privacy Policy
-
www.dotnet247.com