ASP.NET vNext (asp.net 5)

- The cross-platform .NET web stack of the future

Martin Öbrink-Hansen (@martinobrink)

agenda

  1. Introduction to ASP.NET
  2. Motivation for ASP.NET vNext ASP.NET 5?
  3. ASP.NET 5 explained
  4. ASP.NET 5 Visual Studio 2015 Preview demos
  5. ASP.NET 5 on a Mac
  6. ASP.NET 5 Mac demos

Introduction to asp.net

  • A web framework for building Web sites and Web applications using C#, HTML, CSS and JavaScript by Microsoft.
  • ASP.NET 1.0 was released on January 5, 2002 as part of version 1.0 of the .NET Framework => 13+ years old(!)
  • Current version of ASP.NET is 4.5.1 (WebForms / WebAPI 2.2 / MVC 5)
  • Windows/.NET Framework/IIS is required for hosting site/service

What is ASP.NET?

Motivation for asp.net 5

  • Current stack is OLD (13 years)
  • Lots of "heavy luggage" (unused code in the full .NET framework) - particularly System.Web namespace
  • Relying on system-wide upgrades to .NET framework can break existing hosted applications
  • Memory-heavy for even the simplest services
  • The current webstack cannot be pushed further regarding performance

ASP.NET 5 explained - selling points

  • Complete re-write of the ASP.NET web stack
  • Open Source (https://github.com/aspnet)
  • One unified programming model (MVC+WebAPI, no WebForms) 
  • Cross-platform support (Windows/Mac/Linux)
  • Lean(!): opt-in for all modules when needed
  • Core CLR - a "cloud optimized runtime"
    • Side-by-side deployment of runtime + app
    • Low memory footprint: 30kB/req -> 3kB/req

ASP.NET 5 explained - selling points

  • New first-class citizens:
    • NuGet packages/modules
    • Dependency Injection
  • Asynchronous from the ground up
  • Command-line based tooling
  • Roslyn compiler
    • in-memory compilation (no disk I/O)
    • faster dev cycle: save + reload
  • Json-based project/configuration  files
    • xxx.csproj (xml) --> project.json (json)
    • opt-in --> opt-out​

ASP.NET 5 explained - architecture

asp.net 5 explained - commandline

  • KVM: K Version Manager (kvm.cmd/kvm.sh)
    • Install/switch between runtime versions (KRE)
    • kvm -install 1.0.0-beta1
  • KPM: K Package Manager (kpm.cmd/kpm.sh)
    • The ASP.NET 5 equivalent of 'npm' in node
    • Builds/restores packages/outputs NuGet packages
    • kpm build
  • K: Execution Host (k.cmd/k.sh)
    • k <command> <-- starts application

asp.net 5 explained - middleware/services

  • Middleware
    • Code which is injected into the request pipeline
    • Add module XXX (NuGet package) to project.json
    • Startup.Configure(app) { app.UseXXX(); }
  • Service
    • Code which is added to the IoC container for easy consumption by your app code (e.g. Controllers)
    • Add module YYY (NuGet package) to project.json
    • Startup.ConfigureServices(services) { services.addYYY();}

asp.net 5 explained - Startup.cs

//The new Program.cs/main() class

​public class Startup
{
    public void ConfigureServices(IServiceCollection services)
    {

         //add services available via dependency injection
    }

    public void Configure(IApplicationBuilder app)
    {

        //add middleware to the HTTP request pipeline
    }
}

asp.net 5 demo

  • HelloWorld
  • Middleware
    • WelcomePage
    • Custom Middleware
    • Mvc/WebAPI
  • Dependency Injection
    • Calculator
    • SignalR

asp.net 5 on a mac - setup

  1. Install Homebrew (if not already installed)
  2. Run command: brew tap aspnet/k

  3. Run command: brew install kvm

  4. Run command: kvm upgrade

  5. Optional getting started stuff:

    1. clone asp.net/home repo for samples

    2. cd into specific sample folder

    3. Run command: kpm restore

    4. Run command: k run or k kestrel

  6. Start kicking some ASP.NET 5 ass!

asp.net 5 on a mac - ide stuff

  • Install Sublime (if not already installed)
    • plugin: Kulture (ASP.NET 5 build via k)
    • plugin: Omnisharp (intellisense etc.)
    • plugin: C# snippets (foreach etc.)
  • asp.net 5 on a mac - DEMO

  • kvm
  • asp.net/home repo samples

THE road ahead

  • More info

ASP.NET 5 - The .NET web stack of the future

By Martin Öbrink-Hansen