Let's welcome ASP.NET 5

Hello Developers! End of last month Microsoft released the latest version of ASP.NET named ASP.NET 5. Those of you who have been developing for quite sometime might recall the first release of ASP.NET 1.0 almost 15 years ago.  Millions of developers have been using it ever since to build and run web applications.

The latest release is one of the most significant architectural updates done to ASP.NET, whereby ASP.NET is becoming much leaner (it no longer requires System.Web.dll) and more modular (almost all features are now implemented as NuGet modules - allowing you to optimize your app to have just what you need) , cross-platform, and cloud optimized. 

ASP.NET 5 is an open source web framework for building modern web applications that can be developed and run on Windows, Linux and the Mac. It includes the MVC 6 framework, which now combines the features of MVC and Web API into a single web programming framework.  ASP.NET 5 will also be the basis for SignalR 3 which enables real time functionality to cloud connected applications. ASP.NET 5 is built on the .NET Core runtime, but it can also be run on the full .NET Framework for maximum compatibility.

ASP.NET 5 will also mark the following foundational improvements:

  • Build and run cross-platform ASP.NET apps on Windows, Mac and Linux
  • Built on .NET Core, which supports true side-by-side app versioning
  • New tooling that simplifies modern Web development
  • Single aligned web stack for Web UI and Web APIs
  • Cloud-ready environment-based configuration
  • Integrated support for creating and using NuGet packages
  • Built-in support for dependency injection
  • Ability to host on IIS or self-host in your own process.

The end result is an ASP.NET that developers will feel very familiar with, and which is also now even more tuned for modern web development. There a lot changes and improvements, I will list few of my favorites here:

  1. The app is only dependent on features it really needs. Therefore, you are never prompted to update/service the runtime for features that are not relevant to your app. You will spend less time testing and deploying updates that are perhaps unrelated to the functionality of your app.

  2. The app can now be run cross-platform. There will be a cross-platform version of .NET Core for Windows, Linux and Mac OS X systems.  Regardless of which operating system you use for development or which operating system you target for deployment, you will be able to use .NET. The cross-platform version of the runtime has not been released yet, but we are working on it on GitHub and plan to have an official preview of it out soon.

  3. Dynamic Development: In Visual Studio 2015, we take advantage of dynamic compilation to provide a streamlined developer experience. We no longer have to compile our application every time we want to see a change. Instead, just (1) edit the code, (2) save the changes, (3) refresh the browser, and then (4) see the change automatically appear. A development experience that is similar to working with an interpreted language without sacrificing the benefits of a compiled language. We can also optionally use other code editors to work on ASP.NET 5 projects. Every function within the Visual Studio user interface is matched with cross-platform command-line operations.

  4. ASP.NET 5 introduces a new HTTP request pipeline that is modular so you can add only the components that we need. The pipeline is also no longer dependent on System.Web. By reducing the overhead in the pipeline, the app can experience better throughput and a more tuned HTTP stack. The new pipeline is based on many of the learnings from the Katana project and also supports OWIN.

  5. MVC 6 - a unified programming model. MVC, Web API and Web Pages provide complementary functionality and are frequently used together when developing a solution. However, in past ASP.NET releases, these programming frameworks were implemented separately and therefore contained some duplication and inconsistencies. With MVC 6, Microsoft is merging those models into a single programming model. Now, we can create a single web application that handles the Web UI and data services without needing to reconcile differences in these programming frameworks. We will also be able to seamlessly transition a simple site first developed with Web Pages into a more robust MVC application.

  6. MVC 6 - We can now return Razor views and content-negotiated data from the same controller and using the same MVC filter pipeline.

  7. MVC 6 -  new tag helpers feature that let you use HTML helpers in the views by simply extending the semantics of tags in your markup which simplifies customizing the output of HTML helpers with additional markup while letting you take full advantage of the HTML editor. An example, would be instead of using the following:

@Html.ValidationSummary(true, "", new { @class = "text-warning" })

<div class="form-group">

    @Html.LabelFor(m => m.UserName, new { @class = "col-md-2 control-label" })

    <div class="col-md-10">

          @Html.TextBoxFor(m => m.UserName, new { @class = "form-control" })

          @Html.ValidationMessageFor(m => m.UserName, "", new { @class = "text-danger" })

    </div>

</div>

We can instead write directly to the HTML markup:

<div asp-validation-summary="ModelOnly" class="text-warning"></div>

    <div class="form-group">

         <label asp-for="UserName"class="col-md-2 control-label"></label>

         <div class="col-md-10">

            <input asp-for="UserName" class="form-control"/>

            <span asp-validation-for="UserName" class="text-danger"></span>

         </div>

    </div>

Docs and tutorials

To get started with ASP.NET 5 you can find docs and tutorials on the ASP.NET site at https://asp.net/vnext. The following tutorials will guide you through the steps of creating your first ASP.NET 5 project.

You can also read this article for even more ASP.NET and Web Development improvements coming this week.

The ASP.NET 5 preview is now available as a preview release, and you can start using it today by downloading the latest CTP of Visual Studio 2015.

Happy Coding!