Hi All,

I need some help understanding HTTP Modules a lot better.

At the moment I understand creating the Init and Dispose functions and
making the Init function include an event handler.
Its only in the Event handler that I am clueless as to the logic
of getting something to work for you. I am aware of the events available at ones disposal. However can someone explain what goes on in the event handler. I have looked at existing examples of what handlers might be used for but am clueless about the logic.
Thanks very much

p.s also where do i locate the bin file so i can deploy the class module?

public class Module:IHttpModule
{

public void Dispose()
{

}

public void Init(HttpApplication context)
{
app.BeginRequest += new EventHandler(OnBeginRequest);
}

// event handlers
public void OnBeginRequese(object o, EventArgs ea)
{
//Here is what I have no idea what to do.
}

the bin file should be generated with your project. Are you using VS? or are you writing this by hand.

The logic you have is quite simple, the "Init" method is being called and creating a handle of the OnBeginRequest method which should have a set signature.

You are then "+=" appending the handle to the BeginRequest event. When this event is triggered it will loop through all handles that have been added to it (system and user) and trigger them.

This will then fire any code you have in your "OnBeginRequest" method.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.