Category Archives

4 Articles

ASP.Net Core MVC request life cycle – Routing

Routing bridges middleware and MVC framework by mapping incoming Http requests into controller action method. There are two different routing available in MVC.

Routes are evaluated in the order they are defined in the program. The more important routes should be defined first.
Following diagram explain the login flow of routing mechanism in Asp.Net core MVC.

asp.net core mvc routing high level overview


Read More

Comparing Asp.Net core middleware with Http Modules and Handlers

Http Modules & Http Handlers

1. In the older version of Asp.Net, the Http modules hooked into Application lifecycle events to provide reusable services.

2. In the older version of Asp.Net, the Http Handlers were responsible for Generating responses for Http requests.

3. Order of execution of Http modules and Http Handlers are driven by Asp.net life cycle events

Asp.Net core middleware

1. generates responses for requests.

2. Provides application level services and features.

3. Order of execution of Asp.Net core middleware are driven by the order it is added into middleware pipeline.

4. Middlewares are available in Asp.Net web api (.Net 4.5) and .Net core

ASP.Net Core MVC request life cycle – Middleware Pipeline

Middleware Pipeline

ASP Net Core MVC is built on top of a concept called Middleware. Middleware pipeline is a chain of modular components that provide essential building block of how your application handles HTTP request. These components are generating a response for an incoming request directly or with help of a framework such as MVC.

Features like Routing, sessions, CORS, Authentication, Caching etc are implemented as middleware.

Example of asp net core middleware pipeline

Read More

ASP.net MVC 5 controller dependency injection with Microsoft Unity IoC Container

Downloadable source code

Dependency is just another object that a class needs to do its function.
For example, Main program calls a Service class lets say “Customer Class” to update a customer profile. The Customer class generate the required data and creates an instance of Database operations layer (Let’s say “CustomerOperations class”) to update the database tables. In this example, Customer class is dependent on CustomerOperations class to update a customer profile or CustomerOperations class is the dependency of Customer Class.

Read More