• Home
  • About
  • Contact
  • ado.net
  • angular
  • c#.net
  • design patterns
  • linq
  • mvc
  • .net core
    • .Net Core MVC
    • Blazor Tutorials
  • sql
  • web api
  • dotnet
    • SOLID Principles
    • Entity Framework
    • C#.NET Programs and Algorithms
  • Others
    • C# Interview Questions
    • SQL Server Questions
    • ASP.NET Questions
    • MVC Questions
    • Web API Questions
    • .Net Core Questions
    • Data Structures and Algorithms

Wednesday, August 23, 2017

Comparison Between HttpModule and HttpContext

 Abhishek Tomer     August 23, 2017     .Net, Asp.Net, Asp.Net MVC     No comments   

Hi friends! Today we are going to list some of the differences between HttpModule and HttpContext.

Many of my developer friends are confused about HttpModule and HttpContext.
So, Today i am writing this post to help them as well as for the newbies that are starting learning Asp.Net.

So, Let's start with the definition of each.

HttpModule:
Let’s first understand what is HttpModule.It is a.NET Framework class that implements the IHttpModule interface. This is used as filters in IIS these modules filter data or the context inside the request. Every ASP.NET applications uses numerous system modules by default.

HttpContext:
This class implements IServiceProvider interface explicitly. Whenever any new request or response is made HttpContext object is created. This holds all information about the request.

Common things Between HttpModule and HttpContext:
HttpModule and HttpContext work in correspondence with each other in order to serve a module. HttpModule provides information about the user to the UserInfo object. This object is contained inside HttpContext which in turn read this information. HttpModules can start functioning before any other event starts.This provides HttpModule an advantage over MVC request response cycle because using this one can perform various tasks earlier to MVC framework.
HttpModule and HttpContext in Asp.Net
HttpModules and HttpContext
Comparing HttpHandlers and HttpModules
  • Multiple HttpModules can act upon a single request whereas, single HttpHandler can act on a single request only.
  • HttpModules can manipulate the request using various services whereas purpose of using HttpHandlers is to frame response which will be given back to the browser.
  • HttpModules are implemented through IHttpModule interface, and HttpHandlers are implemented through IHttpHandler interface.
  • There is one similarity in both HttpModule and HttpHandler. They both can registered using coding in or using config file.
  • HttpModules can hook up with any MVC lifecycle event but HttpHandler act on events specifically related to mapping and execution only.
MVCRouteHandler and MVCHandler
UrlRouting module is a unique module which contains PostResolveRequestCache event. Purpose of this event is matching of all of the request to the routing table. It executes a RoutingHandler for all of the mappings done by it. RoutingHandler is nothing but a class, which implements IRouteHandler interface. One method of this class is exposed which is named as GetHttpHandler.

This method returns the corresponding MvcHandler (a standard httphandler) for further execution. This uses two methods-
  1. IsReusable
  2. ProcessRequest
Summary:
So, Guys this is all about HttpModule and HttpContext in Asp.Net MVC.

I Hope in this post covered all the points about HttpModule and HttpContext in Asp.Net MVC which will be helpful to understand the concept of HttpModule and HttpContext in Asp.Net MVC.

Please share this post with your friends and colleagues.
For any queries please post a comment below.

Happy Coding 😉
  • Share This:  
  •  Facebook
  •  Twitter
  •  Google+
  •  Stumble
  •  Digg
Newer Post Older Post

0 comments:

Post a Comment

If you like this website, please share with your friends on Facebook, Twitter, LinkedIn.

Join us on Telegram

Loved Our Blog Posts? Subscribe To Get Updates Directly To Your Inbox

Like us on Facebook

Popular Posts

  • Web API Versioning using Query String Parameter
    In this article, I am going to discuss Web API Versioning using the Query String Parameter with an example. Please read our previous artic...
  • Static Files Middleware in ASP.NET Core
    In this article, I am going to discuss how to serve static files using Static Files Middleware in ASP.NET Core Application. Please read ou...
  • Cross-Origin Resource Sharing in WEB API
    In this article, I am going to discuss how to enable Cross-Origin Resource Sharing in Web API which allows cross-domain AJAX calls. Pleas...
  • Custom Method Names in Web API
    In this article, I am going to discuss how to create Custom Method Names in Web API application. Please read our previous article before p...
  • Web API Versioning Using Accept Header
    In this article, I am going to discuss Web API Versioning Using Accept Header with an example. This is a continuation part of our previous...
  • Authentication and Authorization in Web API
    In this article, I am going to discuss the Authentication and Authorization in Web API . Here I will give you an overview of Authentication...
  • Parameter Binding in ASP.NET Web API
    In this article, I am going to discuss one of the most important concepts i.e. Parameter Binding in ASP.NET Web API Application . Please re...

Blog Archive

Contact Form

Name

Email *

Message *

Tags

.Net .Net Core .Net Core MVC Algorithm Angular Anonymous Types Asp.Net Asp.Net MVC Blazor C# Data Structure Database Design Patterns Entity Framework Entity Framework Core Filters Interview Question Management Studio Programming Programs SQL Server SSMS Web API

Copyright © C# Techtics | All Right Reserved.

Protected by Copyscape