• 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

  • OOPS – Difference Between Class and Struct
    Hi friends! Today we are going to discuss a very quite interesting and important topic of Object Oriented Programming(OOPs) i.e. “Classes an...
  • Usability of SecureString object in C#
    Introduction Hi friends! In this blog we will be discussing a very interesting as well as useful topic in C# and that is Securestring objec...
  • ASP.NET State Management
    State management is a technique or way to maintain / store the state of an Asp.Net controls, web page information, object/data, and user in ...
  • Application Life cycle of Asp.Net MVC
    Today i am going to tell you the Application life cycle of an Asp.Net MVC Application, this post is important for those who are new to Asp.N...
  • C# Programming Interview Questions
    Today i am going to tell you some of the basic programming questions that are frequently asked in interview for fresher and experienced as w...
  • Cascading referential integrity constraint in Sql Server
    Hi friends! In our previous sessions we have seen how to create tables and enforce primary and foreign key constraints between them . And in...
  • Model Binding in ASP.NET Core
    In this article, I am going to discuss Model Binding in ASP.NET Core Application. Please read our previous article where we discussed how ...

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