User Id :    Password :      New Member   Forgot Password  
 
What is difference between HTTP Handler and HTTP Module
Description Difference between HTTP Handlers and HTTP Modules.   No. of Views     1720
  Rating     0
Author Jalpesh Vadgama   Posted On     16 Dec 2010
Tags ASP.NET    

Sample Code   Download Code

Http Handlers:

 

Http handlers are component developed by asp.net developers to work as end point to asp.net pipeline. It has to implement System.Web.IHttpHandler interface and this will act as target for asp.net requests. Handlers can be act as ISAPI dlls the only difference between ISAPI dlls and HTTP Handlers are Handlers can be called directly URL as compare to ISAPI Dlls.

 

Http Modules:

 

Http modules are objects which also participate in the asp.net request pipeline but it does job after and before HTTP Handlers complete its work. For example it will associate a session and cache with asp.net request. It implements System.Web.IHttpModule interface.

 

HTTP Handler implement following Methods and Properties

 

  1. Process Request: This method is called when processing asp.net requests. Here you can perform all the things related to processing request.

  2. IsReusable: This property is to determine whether same instance of HTTP Handler can be used to fulfill another request of same type.

 

Http Module implements following Methods and Properties.

 

  1. InIt: This method is used for implementing events of HTTP Modules in HTTPApplication object.
     
  2. Dispose: This method is used perform cleanup before Garbage Collector destroy everything.

 

An Http Module can Support following events exposed to HTTPApplication Object.

 

  1. AcquireRequestState: This event is raised when asp.net request is ready to acquire the session state in http module.

  2. AuthenticateRequest: This event is raised when asp.net runtime ready to authenticate user.

  3. AuthorizeRequest: This event is raised when asp.net request try to authorize resources with current user identity.

  4. BeginRequest: This event is raised when HTTP Modules receive new request.

  5. EndRequest: This event is raised before sending response to client.

  6. Disposed: This event is raised when http modules completes processing of request

  7. Error: This event is raised when any error occurs during processing of request.

  8. PreRequestHandlerExecute: This event is raised just before ASP.NET begins executing a handler for the HTTP request. After this event, ASP.NET will forward the request to the appropriate HTTP handler.

  9. PostRequestHandlerExecute: This event is raised when when HTTP Handler will finish the execution of current request.

  10. PreSendRequestContent: This event is raised just before ASP.NET sends the response contents to the client. This event allows us to change the contents before it gets delivered to the client. We can use this event to add the contents, which are common in all pages, to the page output. For example, a common menu, header or footer.

  11. PreSendRequestHeaders: This event is raised before asp.net Just send response header to client browser.

  12. ReleaseRequestState: This event is raised when asp.net runtime finishes handling of all the request.

  13. ResolveRequestCache: This event is raised to determine whether the request can be fulfilled by returning the contents from the Output Cache.

  14. UpdateRequestCache: This event is raised when ASP.NET has completed processing the current HTTP request and the output contents are ready to be added to the Output Cache.

 

Hope this will help you better understanding of HTTP Handler and HTTP Modules. I will post an real time implementation code in forthcoming blog post.

About Author

About Author I am jalpesh vadgama an Microsoft MVP for Visual C# and BrainBench Certified ASP.NET Developer having more then 5 years of experience in .NET Technology.Please feel free to contact me for any queries via posting comments on my blog I will try to reply as early as possible. Please also visit my blog at http://jalpesh.blogspot.com/ Jalpesh Vadgama
No Photo
 
Country India
Company N/A
Home Page http://jalpesh.blogspot.com/

Rate this article

Rating options from poor, fair, good, very good to excelent.  
 

Comments

   
Write your comment here.
Comment
Verification Code