Jun 30, 2010

HttpHandlers and HttpModules- simple overview

HttpHandlers and HttpModules

===========================

 

- If we want to inject some logic before the page is requested then we can use HttpHandlers and HttpModules. ASP.NET provides two ways of injecting logic in the request pipeline HttpHandlers and HttpModules.

 

 

                Client --------------------------------------------------------------------> Server(.aspx page)

                                 inject some logic here before req reaching to server

 

- Best examples are URL rewriting, authorization and authentication, stat counters, etc.,

 

HttpHandler

===========

 

- HttpHandler - is the Extension Based Preprocessor - injects the logic based on the extension of the page requested.

               

                Client----------------> .aspx

                                Handler1

                      -----------------> . jpg or .gif

                                Handler2

 

- when any client requests for file with extension ‘.aspx’, handler1 pre-processing logic executes.

- a class needs to be implement IHttpHandler interface and provide implementation to two methods ProcessRequest, IsReusable.

 

HttpModule

==========

 

- HttpModule - is the Event Based Preprocessor

- HttpModule events

                BeginRequest

                AuthenticateRequest

                AuthorizeRequest

                PreRequestHandlerExecute

                PostRequestHandlerExecute

                EndRequest

-Modules are called before and after the handler executes.

                Client --> Module --> Module --> Handler --> Module --> .aspx

-implements IHttpModule interface

 

 

 

 

No comments:

Post a Comment