Squelos

ASP.Net 5 (vNext) – A modern web stack

Since Satya Nadella has taken over as Microsoft’s CEO, the company has been undergoing  major changes in order to be become a “services and devices company” rather than the former software company they were up to know, which is known for its Operating Systems and its Office Suite.

Their objective is to offer services that can run on any device, running any OS.

A new stack

ASP.Net’s new version, called ASP.Net 5, translates perfectly this new path that Microsoft has chosen : Services. Indeed, ASP.Net is now Open Source, Cross-Platform, and Cloud Optimized.

Sources are available on GitHub.

Over the years, the improvements that have been made to ASP.Net gave birth to a rather complex code, overlapping namespaces and code duplication.

ASP.Net 5 brings a lot of changes and merges Web Pages and WebAPI into MVC in order to simplify the API.

MVC6 offers a unified programming model : a single controller can serve content pages (MVC) or data (WebAPI).

A Cross-Platform Runtime

In order to run on different Operating Systems, ASP.Net 5 uses a new Runtime : XRE which means : Cross-Platform Runtime Environment. This runtime can target two frameworks :

  • .Net Framework
  • .Net Core

The former includes a more complete version of the .Net Framework whereas the second merely packages essentials elements of the framework, which leads to a lower memory footprint : the Core version comes in at only 45MB, while the .Net Framework comes in at over 400MB.

Each web application comes with its very own runtime version. It is now possible to have multiple applications using different runtime versions on the server. Updating one application to a newer version of the Runtime won’t impact the other applications.

A modular pipeline

ASP.Net 5 comes with a new modular HTTP request pipeline that allows us to plug in only the components we need.

Moreover, this pipeline doesn’t depend on the System.Web namespace anymore. This reduction in the overhead results in better performance.

This new pipeline was built using the experience that was gathered thanks to the Katana project, and … it supports OWIN.

In order to configure your pipeline, you will have to open up the Startup class, and modify the Configure method :

PipelineConfig

In this method, you can also configure the different services that can be injected :

ServiceConfig

 

New Tooling

Visual Studio’s newest version, currently Visual Studio 2015 CTP 6 provides ASP.Net 5 with new tooling, more in line with what modern web developers currently use.

For example, VS2015 provides support for TypeScript, Bower, and also Grunt, via a dedicated toolbar.

TaskRunnerExplorer

 

In order to improve integration in the cloud, the dependency management has been reworked. Each project in the solution uses a few files that declare dependencies and configurations.

  • project.json : declares the NuGet packages dependencies that are required by the project, but also declares some actions that are bound to certain events (loading of the project for instance)
  • package.json : declares the required Node packages (eg. Grunt, Typescript)
  • bower.json : declares the Bower dependencies (grunt sub-tasks etc…)
  • config.json : declares all the configuration variables that might be used, such as the DB connection string