Category Archives

6 Articles
Update Asp net core 2 Angular SPA template to work with Angular 5

Update Asp net core 2 Angular SPA template to work with Angular 5

The source code of this project is added into GitHub, you can download, clone or submit your changes to this repository.
Link to GitHub repository

The project is added to Travis CI to auto build.
Tavis ci build status

My system configuration

  • @angular/cli: version 1.5.5
  • Node: Version 6.11.0
  • npm: Version 3.10.10
  • dotnet: Version 2.0.2

First things first

Before you begin creating a project and updating, let’s look into preparing the environment before we create the project. Run following commands in Command Prompt or shell.

mkdir ng-netcore
cd ng5-netcore
npm uninstall -g @angular/cli
npm cache clean
npm install -g @angular/cli@latest
npm install -g npm-check-updates

Read More

Use Material 2 with Dotnet core 2 Angular 4 spa template

Use Material 2 with Dotnet core 2 Angular 4 spa template

With Dotnet core 2, Microsoft included new Single-Page-Application (SPA) templates for client-side javascript frameworks like Angular, React etc.. In this blog post, I’m going over the steps that require integrating Angular Material 2 into the Angular 4 web application created using dot net core 2.0 angular spa template.


The web applications that created from Dotnet core spa templates (anglar, react etc..) contain a folder called “ClientApp”. This folder holds all the javascript framework components. These applications use TypeScript by default.


Webpack is a module bundler, it takes modules with dependencies and generates static assets representing those modules. Read more about Webpack in this link

The SPAs now support webpack module bundler right out of the box. Web pack runs as part of the build and it does minifications of Javascript and css files as well.
In dotnet core spa template, webpack.config.vendor.js defines all the modules that are relevant to the application. You can add your own css/javascript files to this configuration file. We will use this file to include material javascript components and material theme files. The webpack.config.js file defines all the rules for bundling file, you can add your own rule here as well.
Read More

Mocking objects with Moq and XUnit in .Net Core

Mocking objects with Moq and XUnit in .Net Core

Moq library 4.5 and above supports mocking objects in net Core. This article explains the step by step process that needed to Moq an object in net core. Mocking objects comes in handy when unit testing data store, where a Database can be mocked so that no data is added or modified in Database while unit testing source code.

Creating a test project

For the simplicity of explaining, I’m started with creating a XUnit test project in Visual Studio 2017 15.3

Add Moq package into the project

Read More

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

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