ASP.NET 5 introduces significant changes to the ASP.NET platform. This article discusses the new concepts of ASP.NET 5 and explains how they will help develop modern web applications.
Introduction to ASP.NET 5.
ASP.NET 5 is devoid of the entire redundant .NET stack for building modern web applications. We built it from scratch to provide an optimized platform for developing applications that will be deployed in the cloud or run on our own servers. To support flexibility in building solutions, this platform consists of modular components with minimal overhead.
ASP.NET 5 includes the following features:
- New flexible and cross-platform runtime
- New modular pipeline for HTTP requests
- The configuration is ready to use in the cloud
- Unified software model that combines MVC, Web API and Web Pages
- Ability to see changes without re-building the project
- Use multiple versions of the .NET Framework side by side
- The possibility of self-hosting or hosting on IIS
- New tools in Visual Studio 2015
- Open source in GitHub
The changes we made for ASP.NET 5 were based on customer requests and feedback. These changes simplify development, hosting, and maintenance and are focused on modern web applications.
Your legacy applications will run on the new version of ASP.NET without any modifications. But to take advantage of new features in ASP.NET 5, you need to port the existing code to a new framework. You will find many similarities between ASP.NET 5 and earlier versions of ASP.NET, so porting the code is fixing specific problem areas, not rewriting the entire application.
')
This article presents the direction of ASP.NET 5 development and an explanation of the changes.
Download Visual Studio 2015 Preview
You can already start working with ASP.NET 5 by
downloading the Visual Studio 2015 Preview. For more information on what's included in this release, read the
Visual Studio 2015 Preview .
In this article
Why was ASP.NET redesigned?
The need for a flexible cross-platform runtime environment
In the past, the .NET Framework was used as a single, comprehensive installation. In each new .NET release, new features were added, but the old ones were rarely removed, thus the size of the framework was constantly growing. This approach ensures that a machine with .NET installed can support any type of .NET application, but this means that each application has a dependency on functionality that is not actually used.
If a critical update is needed for one of the technologies in .NET, you receive a notification that an important update is available, even if this part of .NET is not used by your applications. You need to decide whether to install this update and interrupt the application or ignore the update, in the hope that the update is not really necessary.
ASP.NET 5 gives you more flexibility by being able to work in three different runtime environments:
- Full .NET CLR
Full .NET CLR is the default runtime for projects in Visual Studio. It provides the entire API set and is the best choice for backward compatibility. - Core CLR (cloud-optimized runtime cloud-optimized runtime)
Core CLR is a runtime environment for ASP.NET 5 projects. It is free from everything superfluous and is completely modular. This CLR has been converted to a component model, now it is possible to include only those functions that are needed in your application. You simply add components as NuGet packages. As a result, your application depends only on the necessary functions. With this approach to developing a runtime environment, we can deliver component updates faster, because each component is updated on its own schedule. Core CLR takes about 11 megabytes instead of about 200 megabytes for the full version of .NET CLR. Core CLR can be deployed directly with your application and different versions of the Core CLR can work side by side (both of these benefits are described in more detail below). - Cross-platform CLR
We will release a cross-platform runtime for Linux and Mac OS X. This runtime will allow you to develop and run .NET applications on Mac and Linux devices. We work closely with the Mono community. Before release, you can use Mono CLR for cross-platform development. For more information, see ASP.NET vNext Application Development on Mac ( translator's note : the August article is available by reference, there is a post on Habré describing the current state of affairs).
By default, new Visual Studio projects will use the Full .NET CLR. You can specify the Core CLR in the configuration properties of your project.

Hosting anywhere
ASP.NET 5 allows you to host your application on IIS or in self-hosting mode. When you use the Core CLR, you can deploy the application with all the dependencies assembled in the deployment package. Thus, the application and its dependencies are completely autonomous and are no longer dependent on the installation of .NET on the system. The application can work on any type of device or hosting platform.
This new feature gives a lot of freedom. We still recommend IIS as the best option for hosting, but you can, if necessary, use another hosting platform. Your hosting settings no longer determine which framework to use for development and vice versa.
Example of hosting an application outside of IIS:
Creating a web API in MVC 6 .
Use different versions of .NET side by side
When applications on a server depend on one, system-wide installation of the .NET Framework, all applications run on the same version of .NET. This situation creates some concern when considering upgrading to the new version of the .NET Framework. You may want some of your applications to use the latest version of .NET, but you are not sure that all your old applications will work properly with the new version.
Fortunately, ASP.NET 5 fixes this problem. You can define dependencies within a deployment package and specify the .NET version for each application. You get all the benefits of the latest version for some applications and just keep using the old version for the rest. All these different versions work side by side without any problems. To run applications with different versions side by side, you must select a target Core CLR for them.
Simplify dependency management
ASP.NET 5 introduces a new, easy way to manage dependencies in your projects. You no longer need to add references to assemblies to a project; instead, you manage dependencies by referring to NuGet packages. You can add NuGet packages using the NuGet package manager, or you can edit the JSON file (project.json), which lists the NuGet packages and versions used in your project. To add other dependencies, you simply write the name and version number of the NuGet package in the project.json file.

In Visual Studio 2015, IntelliSense helps you find available NuGet packages.

The project.json file includes only NuGet packages that were directly added to the project. If you add a NuGet package that depends on other packages, these secondary dependencies are loaded but not listed in the project.json file. This approach allows you to keep the project.json file uncluttered and easy to manage. If you remove the NuGet package from project.json, the secondary dependencies are also removed if there are no other packages that need them.
Thanks to the JSON format, managing dependencies is easy, even if Visual Studio is not installed. You can open the project.json file in any text editor and make changes, for example, update the dependencies of an application deployed in the cloud.
Eliminate duplication in MVC, Web API and Web Pages
In the past, MVC, Web API and Web Pages contained various implementations of similar functionality. For example, MVC and Web API provide routing, but MVC routing classes are located in the System.Web.Mvc.Routing namespace, and similar Web API classes are located in System.Web.Http.Routing. Or, Web Pages and MVC use the Razor syntax, but some NuGet packages are only compatible with one or the other.
In ASP.NET 5, MVC, Web API and web pages will be merged into a single framework called MVC 6. This merge removes duplications from the framework and makes application development easier. You no longer need to write slightly different code depending on whether MVC, Web API or Web Pages is used.
In this preview version, MVC and Web API were merged into MVC 6.
Web Pages will be added to MVC 6 in a later version.HTTP performance enhancement
ASP.NET 5 introduces a new software pipeline for HTTP requests, which is free from everything superfluous. This pipeline is modular, you can add only those components that are needed. The application will have more bandwidth due to lower overhead. The new conveyor also supports
Owin .
Ready for use in the cloud
When you create a new ASP.NET 5 project, this project is structured for easy deployment in the cloud. Visual Studio 2015 provides a new environment configuration system that replaces the Web.config file. The new system allows you to query the named values from various sources (for example, JSON, XML, or environment variables). You specify values for each environment, and after deployment, your application simply reads the correct values.
We also provide diagnostic and trace tools that make it easy to detect application problems in the cloud.
Integration of dependency injection
Dependency injection is built into ASP.NET 5. You can use your IoC container to register dependencies. Injection dependency makes it easy to provide the right services for the environment of use. For more information, see
Dependecy Injection in ASP.NET vNext .
Open source code and make transparent
All code for ASP.NET 5 is available on
GitHub . Not only is the code available, we use GitHub repositories for our entire development. You can see exactly what changes were made and when they were made. You can download the code and submit the changes.
By developing ASP.NET 5 in GitHub, we make it easier to understand the code and our intended development. You can offer your edits or develop a custom implementation of ASP.NET.
Provide a flexible development environment
Visual Studio 2015 offers a lightweight approach to developing ASP.NET applications. You simply make changes to the code, save the changes and refresh the page in the browser. You will see changes to the browser without re-building the project.

You can change the web project code or the class library code referenced by the project. You can run (CTRL + F5) a project, and not be in debug mode to see the changes.
Visual Studio uses the
Roslyn compiler for dynamic compilation. You still have access to the full power of the compiled framework, but the design creates the feeling of using an interpreted language.
Each function in the Visual Studio GUI corresponds to a command line operation. You can easily switch between using the interface and writing scripts on the command line.
Finally, you can use other code editors for projects on ASP.NET 5.
What about Web Forms?
You can continue developing your application using Web Forms and be fully confident that Web Forms are an integral part of the .NET web development platform. We are still focused on adding new features for Web Forms so that the development experience is consistent with modern web practices.
Web Forms 4.6 includes the following new features:
- HTTP 2
- Asynchronous binding model
- Roslyn CodeDOM compilers
Existing Web Forms applications will continue to run unchanged on IIS with .NET 4.6. You cannot use Web Forms applications with the Core CLR.
The
link is a video of new features in Web Forms 4.6. For a description of the many changes to Web Forms in Visual Studio 2013 Update 2, see
Improvements to ASP.NET Web Forms.What about old apps?
Perhaps you are concerned that with so many changes in ASP.NET 5, now you will need to rewrite all your applications? Do not worry. Applications built on earlier versions of ASP.NET will continue to work with the new .NET Framework. You do not need to update or port these applications unless you need the new features of ASP.NET 5.
For example, your applications that currently use Web Forms, MVC 5, Web API 2, SignalR 2, Web Pages 3, or Entity Framework 6 are fully supported in the new framework without changes. However, you must use the full .NET CLR to run older applications, because only in this CLR is full compatibility with earlier versions ensured.
Core CLR has a slightly limited API. To use the Core CLR, an application must use only those types and members that are available in this runtime environment.
To ensure that your application can run in the Core CLR runtime, use the
API Portability Analyzer . This tool tells you which platforms your application can run on and which dependencies block the launch of the application on other platforms. It will help you understand the scope of the required changes and suggests new types or members to replace unsupported ones.
MVC 6 and SignalR 3 applications use the new HTTP pipeline, so they are not compatible with applications that use System.Web. To upgrade an existing application to MVC 6 or SignalR 3, you must create a new project in Visual Studio 2015, and then transfer the code to a new project. When migrating, you need to change the unsupported code.