Shibu Thannikkunnath

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. 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 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

Dot net standard demystified: What, why and how?

Portable class Libraries and the Problem

In the beginning building applications for .Net was simple, developer had only one framework to target while building the application. This changed when Silverlight came. developers wanted to share libraries for Silverlight and .Net framework. Which caused the origin or Profiles.


Profiles are a set of reference libraries, that have references to the libraries available in different platforms. In order to make sure any specific code can be portable, you can compile your code against to specific Profile.

  • Profile 14
  • .Net framework 4.0
  • Silverlight 5.0
  • Profile 37
  • Profile 14 (.Net framework 4.0 & Silverlight 5.0)
  • .Net framework 4.5

Read More

ASP.Net Core MVC request life cycle – Overview

ASP.Net Core MVC request life cycle – Overview

Overview of Platform changes
In the past version of ASP.Net, Web forms and MVC used to share the underlying infrastructure. In .Net core these platforms are unified into one MVC. The Webforms is not part of ASP.NET core anymore.

The prior versions of ASP.NET MVC used to provide an underlying application life cycle events based on HTTP modules & handlers and IIS hosting and application level events . Http Events and Handlers are not existing in ASP.NET Core.

Most of the events and functionality are provided in ASP.Net core by middleware.

What is life cycle
A Series of components, events or stages of an application that processes a request or respond to user interaction. In MVC the request life cycle refers to all of the components and stages that interact to process an HTTP request.

Following diagram shows an overview of ASP.Net core MVC application.

Asp.Net Core MVC Life cycle overview

Read More

NUnit change order of test run

In version, 3.2 NUnit introduced a new attribute called “Order” to control the order of unit test cases run while running a test suite.

Test cases with Same order number are considered as one, NUnit will decide the order of their run.

The test cases do not have an Order number will follow the regular test run ordering. The Unit tests that have an Order number will always take precedence in Test Run.

Example source code is provided below.
Read More 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

The type or namespace name system could not be found Error in C#

How to resolve “The type or namespace name system could not be found” and “Predefined type system object is not defined or imported” errors in a .Net project c#?

Install the latest version of System.Runtime Nuget package or add a reference to System.Runtime from “Add references”.

Clean and rebuild the project once Reference is added.

PM> Install-Package System.Runtime

Read More

Installing Net core in Ubuntu 16.04 LTS

.NET Core is a cross-platform, open-source, and modular .NET platform for creating modern web apps, microservices, libraries and console applications.

As of 4/23/2017, the latest version of dotnet core for Linux is version 1.0.1.

Run following commands in a shell to install dotnet core in Linux 16.04 LTS.

ssudo sh -c 'echo "deb [arch=amd64] xenial main" > /etc/apt/sources.list.d/dotnetdev.list'

Read More