• 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

  • What is Dependency Injection(DI)
    Hi friends! Today we are going to learn about Dependency Injection and in our last session we have come across Static classes and where it s...
  • C# Programming Examples on Sorting
    Today i am going to tell you some of the Sorting programming questions in C#. Q1- Write a C# program to perform Selection sort. Ans:  Sel...
  • Calling Web API Service in a Cross-Domain Using jQuery AJAX
    In this article, I am going to discuss Calling Web API Service in a Cross-Domain Using jQuery AJAX . Please read our previous article befor...
  • ViewBag in ASP.NET Core MVC
    In this article, I am going to discuss the use of ViewBag in ASP.NET Core MVC application with examples. Please read our previous article ...
  • Recursion And Back Tracking
    In this article, I am going to discuss Recursion And BackTracking in detail. Please read our previous article where we discussed Master Th...
  • What is Abstract Class and When we should use Abstract Class
    Hi friends! In our previous sessions we have seen  Difference Between Class and Struct . And in our last session  we learnt Usability of Sec...
  • Binary to Decimal Conversion in C# with Examples
    In this article, I am going to discuss the Binary to Decimal Conversion in C# with some examples. Please read our previous article where w...

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