Introduction to ASP.NET 5
Transcript of Introduction to ASP.NET 5
• What's wrong with current ASP.NET and why
change it?
• So, what's changed?
• OWIN, modularity, bye-bye sytem.web
• Changes that matter to developers
• New project structure, JSON configurations, Roslyn,
dependency management, compiling for multiple
platforms
• The "K" world
• MVC 6 features
• POCO controllers, DI
Agenda
Current ASP.NET stack
Windows Server
IIS
.NET Framework
ASP.NETWeb
FormsMVC Web API
Sys
tem
.Web
HTTP
Modules
HTTP
Handlers
Request
PipelineCaching
Session
State
• Limited hosting possibilities (IIS only)
• Dependency on IIS environment (System.Web)
• Web evolves faster than .NET framework
• Requires full-blown .NET framework - resource
intensive and not web-friendly
• Hard to optimize for lightweight high-performance
apps
• Not completely cloud-optimized
Problems with ASP.NET architecture
Introducing ASP.NET 5 stack
OS
.NET CLR
ASP.NET
Web API MVC Web Pages
Host
IIS Self-hosted
.NET Core CLR
OWIN
• Totally modular
• NuGet is first-class citizen in ASP.NET 5
• Everything is a package
• Lightweight - you use minumum set of modules
• Faster startup, lower memory (>90%)
• Does not require .NET Framework installation -
runtime environment (CLR) can be deployed with
your application
Key improvements in ASP.NET 5
Key improvements in ASP.NET 5
• Cross platform - can be hosted anywhere:
• IIS, self-hosted, Linux, MAC...
• Web Forms are left aside for now
• Better developer experience
• No-compile debugging with Roslyn, MVC unified
programming model, basic DI out-of-the-box...
• Everything is open-source
• Architecture is OWIN based
Let's talk about OWIN
• Open Web INterfaces
• Public standard created by Microsoft
(http://owin.org/)
• Decouples application from server
• Enforces modularity of the server
• Stack of modules (middlewares) is processing the
request from application to server
• Microsoft implementation of OWIN is "Katana"
Katana implementation
Host
Middleware
Server
Application
Middleware
Middleware
Request Response
Startup, bootstrapping,
process management
Manages sockets,
delegates to middlewares
Pass-through
components stack
Your code
• Modularity - small and focused components
• Flexibility - gives control to use only needed
middlewares
• Performance - uses fewer computing resources
• Scalability - add new middlewares on demand
• Portability - host application anywhere
• ASP.NET pipeline on IIS
• ASP.NET pipeline without IIS (Kestrel web server)
• Self-hosted
• OwinHost.exe
Power of Katana
Katana implementation
• There are two important objects in Katana
implementation:
• Environment dictionary: IDictionary<string, object>
• Application delegate: Func<IDictionary<string, object>, Task>
...owin.RequestBodyowin.RequestHeadersowin.RequestQueryStringowin.RequestProtocol...
• ASP.NET 5 is still in preview
• Comming with Visual Studio 2015,
currently available version is CTP 5
You can try it while it's hot!
• Dependencies - lists all the dependencies of your
application (NuGet, source files, etc.)
• Configuration - compilation settings (debug, release)
• Frameworks - target frameworks with their
dependencies
• Sources - what should be compiled
• Web root - server root of the app
• Shared files - files shared with dependent projects
• Commands - commands available to "K.cmd"
• Scripts - pre/post events to hook scripts to
• Metadata - general project information
Structure of the "project.json" file
• KRE - Runtime Environment• Engine that runs your application (compilation system,
SDK tools, and the native CLR hosts)
• KVM - Version Manager• Tool for updating and installing different versions of KRE
• KPM - Package Manager• Tool to restore and install (NuGet) packages needed by
applications to run
• K• Entry point to the runtime - starts the runtime with
commands
"K" command line tools
ASP.NET MVC 6
Web Pages + MVC + Web API =
ASP.NET MVC 6!
• Comes with package Microsoft.AspNet.Mvc• One controller type for all
• Microsoft.AspNet.Mvc.Controller or
POCO controller
• Built-in DI support for environment services• Can be replaced with your favourite (Ninject,
Autofac...)
• ASP.NET home page:
• http://asp.net/vnext
• Code:
• ASP.NET 5: http://github.com/aspnet/home
• .NET Core: http://github.com/dotnet/home
• API Portability Analyzer:https://www.microsoft.com/en-
us/download/details.aspx?id=42678
Resources