CodeDigest.Com Logo
Featured:

Breaking Changes and New Features of Asp.Net Core MVC (Asp.Net MVC 6.0)

Tagged as: Asp.Net Core Asp.Net Core MVC Posted By

Asp.Net Core is the next big release in Microsoft’s web application stack. The release of Asp.Net Core has brought in many breaking changes to the application framework and it has started a new era of developing web applications. Microsoft entered the big league of open source community by making Asp.Net Core as completely free and open source.

The intention of this article is to give you a brief idea on breaking changes the Asp.Net Core framework has brought to the Microsoft's web stack and the new features it offers in Asp.Net Core MVC.

  1. Platform Independence

Until the release of .Net Core framework, the .NetFramework (Full .NetFramework) is designed to run on only Windows based machines. To address the changing needs of market and to offer the .Net capability to other platforms, Microsoft re-designed the .NetFramework and Asp.Net framework from scratch to support multiple platforms like LINUX, Mac, etc. This re-implementation is called .Net Core and Asp.Net Core. The Visual Studio IDE, the primary tool for .Net development has added another version called Visual Studio Code for developing application in Linux and Mac operating systems.

  1. No Dependency on IIS Web Server

IIS (Internet Information Services) is the default webserver for hosting Asp.Net applications all these days. When Asp.Net Core is offering platform independence, it has to naturally support many other webservers other than IIS. This means that the Asp.Net’s dependency with IIS has to be removed at first place. This was the intention behind developing the OWIN specification. The Asp.Net Core has a new implementation of OWIN which has broke the framework dependency with IIS and gave way to host Asp.Net application under other webservers. The Asp.Net Core MVC applications can now be hosted behind webservers like Nginx, Apache and IIS. Additionally, Asp.Net Core deployment model uses an in-process webserver called Kestrel and uses IIS, Nginx and Apache as a reverse proxy server.

Read the below article to know more on Deploying and Hosting Asp.Net Core applications.

Beginning Asp.Net Core - Part 4 - Deploying and Hosting Asp.Net Core Application

  1. Fully Open Source and Modular Framework

.Net Core and Asp.Net Core are released as open source projects. The GitHub repositories below.

https://github.com/dotnet/core

https://github.com/aspnet/Home

The Asp.Net Core framework is designed as a modular framework. Now, the developers have the control to compose the required framework components and include only those framework component libraries into the project. To faciliate this, the .Net Core libraries, Asp.Net Core libraries and the runtimes are available as Nuget packages.

The framework's modularity has added another flexibility to include the required framework and runtime components as part of the application deployment package itself. This means Asp.Net Core applications can be deployed as stand alone deployments without depending upon the machine wide framework installations.

Read the below article on creating deployment package to know more.

Beginning Asp.Net Core - Part 3 - Creating Deployment Package

  1. Designed for Cloud Deployments

Since Asp.Net Core is a modular framework, it supports containerisation of the Asp.Net Core apps with containers like Docker. There are other changes like the configuration system is much customized to make the cloud transition a easier task. This all makes the Asp.Net Core a cloud ready platform.

  1. Works with Full .Net Framework and .Net Core

Asp.Net Core application can be run on both .Net Core and full .NetFramework runtime.

  1. No More HttpModules and HttpHandlers, it’s only Middlewares

The Asp.Net HttpModules and HttpHandlers are no more in Asp.Net Core framework. It’s all middleware components in the request processing pipeline in Asp.Net Core applications. The middleware components can be configured from the Startup class Configure() method. In general, the Asp.Net Core request processing pipeline is setup with chain of middleware components that does filtering and short circuiting request processing before passing it to MVC.

  1. dotnet CLI

.Net Core includes a new cross platform Command Line Interface for managing all development activities from command line. There are commands available for each activities like creating project, build project, restore packages, creating deployment package, etc.

Read Quick Start article Learn dotnet CLI Commands to know more.

  1. Web API (REST API) and MVC Controller are Unified

The Web API and MVC controller implementation in Asp.Net Core MVC framework are unified into a single framework. This means both the controllers now derive from Microsoft.AspNetCore.Mvc.Controller class.

  1. Tag Helpers

Tag Helpers is a new feature added in Asp.Net Core MVC framework which helps to extend the view HTML elements. They are similar to HTML helpers but mostly helps to replace the use of HTML helper methods.

Read the below article to know more about Tag Helpers.

Understanding Tag Helpers in Asp.Net Core MVC

Creating Custom Tag Helpers in Asp.Net Core MVC

  1. View Components

View Components is another new feature added in Asp.Net Core MVC to develop re-usable components like login panels, tag clouds, recent articles widget, etc. View Components in Asp.Net Core MVC replaces the child action methods of previous version of MVC.

Read View Components in Asp.Net Core MVC to know more about View Components.

  1. In-built Support for Dependency Injection Container

The previous version of Asp.Net MVC frameworks are designed to support Dependency Injection by using third party IOC containers like NInject, StructureMap, Autofac, etc. ASP.NET Core MVC includes a complete DI implementation as part of its in-built framework and is used extensively by MVC internally. This means we can register our application dependencies using this in-built framework and it will take care of instantiation of dependent object. All the dependent services should be registered at Startup class ConfigureServices() method.

For detailed read, Using In-built Dependency Injection Framework in Asp.Net Core MVC

  1. View Injection

Similar to injecting dependency on constructor, Asp.Net Core MVC supports dependency injection to Views. To inject dependency service to view, we have @inject directive.

Syntax: @inject [servicetype] [name]

The service we are injecting should be registered in Startup class ConfigureServices() method.

For detailed read, View Injection,Action Injection and Resolving Framework Services using Asp.Net Core MVC DI Container

  1. Cookie-based TempData provider

TempData in Asp.Net Core MVC can be configured to store its content in user cookie. We have CookieTempDataProvider for this which should be enabled from ConfigureServices() method of Startup class.

 

public void ConfigureServices(IServiceCollection services)

{

  services.AddSingleton<ITempDataProvider, CookieTempDataProvider>();

}

 

  1. wwwroot for Static Files

Asp.Net Core MVC project has a special folder called wwwroot to store the static files like html, images, css, fonts and javascript files. The Asp.Net Core application has a middleware to serve the static files under wwwroot folder. This middleware will directly resolve all the request to the static files without passing it to MVC.

  1. Json Based Configuration Files and Other Configuration Providers

Asp.Net Core MVC projects includes configurations in Json based files by default. Example: appSettings.json, bundleconfig.json.

The configuration data in Asp.Net Core apps can also be managed with different configuration providers like Environment Variables, Command Line parameters, Azure Key Vault, etc.

  1. Automatic Compiling or Back Ground Compiling

The Roslyn .Net compiler performs automatic background compilation of the C# files once the code files are saved. This means a browser refresh will get the changes made without a explicit re-compilation.

  1. Open Source Tooling Support

Asp.Net Core MVC project supports many tooling from open source community. Some of the tools are npm package manager, bower, gulp, grunt, etc. Read the below quick start article to know more.

What is Gulp? How to Use Gulp?

Using Gulp (gulpfile.js) in Visual Studio 2017

Learn Bower Package Manager in 10 Minutes

  1. Unit Testing with xUnit.net

The previous version of Asp.Net projects use Visual Studio Unit Test framework for unit testing by default. For Asp.Net Core, a new unit testing framework called xUnit.net is used.

 

Further Reading on Asp.Net Core

Read the below introductory articles to understand and starting Asp.Net Core application development.

  1. Start Learning Asp.Net Core - Part 1 - Introduction and Understanding the Basics & Fundamentals

  2. Start Learning Asp.Net Core - Part 2 - Understand Project Structure and Startup Class in Visual Studio 2017

  3. Start Learning Asp.Net Core - Part 3 - Creating Deployment Package

  4. Start Learning Asp.Net Core - Part 4 - Deploying and Hosting Asp.Net Core Application

 

 

 

 



Feedback

Comments