asp.net vnext the future of asp

23
vNext THE FUTURE OF ASP.NET

Upload: clement-hallet

Post on 15-Jul-2015

118 views

Category:

Technology


0 download

TRANSCRIPT

vNextTHE FUTURE OF ASP.NET

Where we go?ASP : Summary

New structure + Demo

OWIN

Grunt

Bower

Dependancy Injection + Demo

Kruntime + Demo

OmniSharp & YO

ASP : Summary (1/2)

ASP.NET = 2002 :◦ Webform, (ViewState)

◦ System.Web (releases sync with releases of the framework)

◦ HttpContext (designed for webform)

More than 30Ko of server’s memory each request (HttpContext)◦ Even for REST API’s !

ASP : Summary (2/2)ASP .NET MVC = 2007

◦ MVC, WebAPI, SignalR, Razor are all Nuget packages

WebAPI = 2012

ASP.NET vNext = 2015◦ OWIN (Open Web Interface for .NET - Katana)◦ CIAO system.Web!◦ Modular framework in packages◦ Cloud optimized (200 -> 10MB for the framework)◦ Official support of Mono (mono in integration build)◦ Grunt and Bower integration◦ Kruntime: deal framework packages thanks to KVM & KPM◦ Dependancy injection built-in◦ EF7 (Wphone , Mono Azure & SQLite(?) compliant)◦ Identity 3◦ …

New structure! (1/2)Solution items

◦ Global.json : information about solution

Src : contains projects, source files (not unit test)

Wwwroot : static files (scripts, css, pictures, font,…)

Config.json: new config file

Project.json : contains all packages used and dependancies (ex: asp.net MVC), file for NuGet

Startup.js (entry point for OWIN (before: global.asax)) :◦ Startup : Setup configuration

◦ ConfigureServices : called by the runtime: loads EF, Identity, MVC, Singleton for DI

◦ Configure : called after after ConfigureServices : loads and configure

◦ HTTP request pipeline, identity, error handling, routing, …

New structure (2/2)Global information on the project

◦ WebRoot: web server root (public folder)

◦ Metadata as version, authors, description

◦ Things to exclude for compilation

Dependencies section lists :◦ all the dependencies of your application

Target frameworks that will be built, and dependencies that are specific to the configuration.

DemoLaunch of starter

The new compiler Roslyn is there! (control+F5 in order to use the AOT compilation : build is donewhen you save, VS just do semantic check)

OWINOpen Web Interface for .NET runs MVC applications on a very thin Katana server, or on a Project Helios managed IIS instance.

Interaction between webhost and web app that allow to be ran on different platforms (Linux, OSX, Windows) thanks to their 4 layers:

GruntGrunt = JS Task-Runner

◦ Automate everything !◦ CSS concat

◦ JS minifier

◦ Picture optimization

◦ …

◦ Package.json ->

◦ GruntFile.js

BowerClient-side package manager (dependency mgmt tool)

Configuration in bower.json

Dependancy Injection (1/5)

Dependency Injection" is a 25-dollar term for a 5-cent concept. [...]

Dependency injection is basically providing the objects that an object needs (its dependencies) instead of having it construct them itself. It's a very useful technique for testing, since it allows dependencies to be mocked or stubbed out.

Dependency injection == giving an object its instance variables.

Dependancy Injection (2/5)Example application that shows TODO items

The demo front-end just show the items but there are some backend methods as example.

Dependancy Injection (3/5)TodoRepository that implements ITodoRepository

Dependancy Injection (4/5)Controller

Dependancy Injection (5/5)ConfigureServices is the global place where dependencies are registered that can be used through the whole application stack.

AddSingleton method register the Interface and the specific implementation of the global DI container.

Demo !Let’s launch that beautiful app ( sorry, no more pictures )

K* (1/2)KRE = K Runtime Engine : code to bootstrap apd run ASP.NET vNext (Compilation system, SDK, tools, CLR hosts, …). KRE = packages !

KVM : K Version Manager : to manage install different version of KRE present on the machine. Usedto set default KRE version (powershell script)

KLR = K Language Runtime: used to launch one self hosted app. When used, KLR find and launch CLR native host of the app

KPM : K Package Manager : to manage NuGet packages and dependancies needed to run the app

K* (2/2)Kvm help !!!

kvm list : list all versions of the framework and the one that is selected (the one with a *). Whenthere is a « C », it’s cloud optimized!

Kvm alias default 1.0.xxx (and restart VS) : put alias default to 1.0.xxx

Kvm use 1.0.xxx : set active version for machine

Kvm use default : set active version for machine but by specifying that one that is default

k run: execute the application on CLI & K web: for webapplication

K web --server.urls=http://localhost:5001 in order to specify url if not specified in config file

Demo

Test project with commands!◦ Console

◦ Web

◦ Web with different version of runtime

OmniSharpTool To enable great .NET development in lots of editors:

◦ Atom

◦ Sublime text 3

◦ Brackets

◦ VIM

◦ Emacs

◦ CLI

YO !Yeoman : tool to generate code : a scaffolding too for aspnet from the CLI:

Question?

Sourceshttp://en.wikipedia.org/wiki/ASP.NET_MVC_Framework

http://developer.telerik.com/featured/microsofts-special-k-an-introduction-to-asp-net-vnext/

http://gruntjs.com/

http://gunnarpeipman.com/2014/10/asp-net-5-new-structure-of-solutions-and-projects/

http://www.omnisharp.net/

https://robinsedlaczek.wordpress.com/2014/11/22/dependency-injection-in-asp-net-vnext/

http://fiscammc.com/wordpress/category/owin/

www.owin.com

www.yeoman.io

www.omnisharp.com