.NETGURU
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




ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
Ad


Need Dot Net Interview Questions?
Ask ExamGuru, Inc. for advice and help on Passing .Net Interviews
.Net Projects
Best-of-breed application framework for .NET projects, developed by ExamGuru, Inc. and ExamGuru IT
Free .net Help
Commission ExamGuru, Inc. and his team for your next bespoke software project
FogBUGZ
The only bug tracking system carefully crafted with one goal in mind: helping teams create great software.
Awesome Tools
If you don't know about these, you're missing out... IT Certification Questions
IT Interview Questions
Free Oracle 10g Training
MCSE Boortcamp
Cisco Study Guides
Cheap Study Guides
Exact Questions
Dot Net Interview Questions
Oracle OCP
Cheap Travel
Designer Perfumes - Wholesale Prices
Free Programming Tutorials
 
ExamGuru IT Solutions - .Net Guru is owned and operated by ExamGuru, Inc., the man behind .Net Guru. If you're in the market for bespoke software or software consultancy, why not get him and his highly trained team to help? - www.examguru.net/ITCertification
 Copyright © ExamGuru, Inc. 2001-2006
Contact Us - Terms of Use - Privacy Policy - www.dot-net-guru.com - www.examguru.net - www.oraclesource.net - www.itinterviews.net - www.examguru.net/ITCertification