ASP.NET vNext (asp.net 5)
- The cross-platform .NET web stack of the future
Martin Öbrink-Hansen (@martinobrink)
agenda
- Introduction to ASP.NET
- Motivation for
ASP.NET vNextASP.NET 5? - ASP.NET 5 explained
- ASP.NET 5 Visual Studio 2015 Preview demos
- ASP.NET 5 on a Mac
- 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
- Install Homebrew (if not already installed)
-
Run command: brew tap aspnet/k
-
Run command: brew install kvm
-
Run command: kvm upgrade
-
Optional getting started stuff:
-
clone asp.net/home repo for samples
-
cd into specific sample folder
-
Run command: kpm restore
-
Run command: k run or k kestrel
-
-
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
- http://channel9.msdn.com/Series/Whats-New-with-ASPNET-5
- https://github.com/aspnet/Home
- http://www.codemag.com/Article/1501061
- http://www.codemag.com/Magazine/Issue/c285ab50-86a9-44c3-a0ce-d790acae7db1
- http://www.tugberkugurlu.com/archive/exciting-things-about-asp-net-vnext-series-the-ultimate-guide
- https://www.jeremymorgan.com/tutorials/vnext/how-to-build-c-sharp-on-mac-osx/
- ASP.NET 5 community standup: https://www.youtube.com/playlist?list=PL0M0zPgJ3HSftTAAHttA3JQU4vOjXFquF
ASP.NET 5 - The .NET web stack of the future
By Martin Öbrink-Hansen
ASP.NET 5 - The .NET web stack of the future
- 1,069