42
AMBIENT INTELLIGENCE tech days 2015 # mstechdays techdays.microsoft.fr

ASP.NET MVC 6

Embed Size (px)

Citation preview

AMBIENT INTELLIGENCE

tech days•

2015

#mstechdays techdays.microsoft.fr

ASP.NET MVC6

Rui Carvalho@rhwy @paulcociuba

Paul Cociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

.Net Escalation Engineer pour Microsoft France- développeur web ( ASP.Net et IIS ) depuis 10 ans

- interface entre le groupe produit ASP.net, le support et les clients Microsoft

- blog: http://blogs.msdn.com/friis

- site de gestion des favoris en ligne: http://linqto.me

-packge Nuget Azure Black IP

-passionné de l’aviation civile et gestion du trafic aérien

Paul Cociuba

Cloud Favorites

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Artisan Logiciel indépendantRui Carvalho

Développement .net web, Conseil, coaching, formation

Conférence internationnale de développeurs .Net à Paris Talks mensuels, coding dojos, open spaces

http://www.meetup.com/altnetfr http://ncrafts.io

C#, F#, Architecture, DDD, Cqrs, sofrware craftsmanship,+

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Prochains évènements

NCRAFTS

21-22 MAI 2015

Code : TD2015-MVC6

Talks : 19 Mars

http://www.meetup.com/altnetfr/events/220455512/

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

WHAT’S NEW ?

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Tout !

(mais pas tant que ça)

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

1996

ASP

2002

ASP.NET

2008

ASP.NET MVC

2010 20122014

K

(webforms)

Web pages

SignalR

Web API

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

1996

ASP

2002

ASP.NET

2008

ASP.NET MVC

2010 20122014

K

(webforms)

Web pages

SignalR

Web API

6 ans 6 ans 6 ans

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

(c’était presque simple)

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Html Helpers Html Helpers

Controllers

Actions

Filters

ModelBinders

Controllers

Actions

Filters

ModelBinders

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

TOO BIG!Legacy

Duplication

System.Web

Complicated Tools

Does Not match

today needs !

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

MVC 6

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

ASP.NET MVC 6

=

( MVC

+ Web API

+ Web Pages)

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

OPEN SOURCE

GITHUB

Command

Line First

Simplicity

CROSS Platform

Package

First

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Visual Studio 2015 preview

K runtime

http://www.asp.net/vnext

Windows / Mac / Linux

https://github.com/aspnet/home

1. install the runtime manager (KVM)

2. install last runtime (KRE) : kvm upgrade

3. Install nuget packages (KPM) : kpm restore

4. Run project command (K) : k {command}

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Un nouveau répertoire

Un Project.json

Un fichier de code : Startup.cs

Puis kpm restore && K web

Plus besoin de csproj xml, de msbuild, de

declarer les fichiers sources …(ceux que vous verrez ne sont utilisés que par Visual Studio)

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

(Même principes que pour Web API2+Owin)

Ajout de MVC au pipeline owin:

Configuration des routes:

DI / Services (obligatoire):

Le point d’entrée

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Pas de classe de base obligatoire : convention

Sinon héritage de Controller

Même controller pour Web UI et Web API

What’s new

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Les tâches de base peuvent se faire dans le template

Extensible

Attribute routing (web api mode) directement sur le verbe

Less ceremony

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Note: le M dans MVC c’est un ViewModel pas un Model …

Attributes:

Better Magic …

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Plus de dependency resolvers pour mvc et webapiséparés !

Tout peut se faire via la configuration de services

Un implémentation de DI de base livré par défaut !

Des Adapters pour toutes les libs de DI

Anti-patterns land

Note: DI est juste un outil, parfois utile pour aider à l’inversion de controle …

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Plus de service locator SVP !

(évitez l’injection de propriétés aussi)

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Un outil de configuration simple a été ajouté

On peu chainer les configs (les + récentes prévalent sur les +

anciennes):

On peu persister des changements!

modern

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Html Helpers v2

Injectables

Sortes de web controles passifs

Sortes de Mini-Controllers

Traitement C#

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

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

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

• Pas encore très sec!

• Mais OSS !• Toutes les sources

• Toutes les issues (et fix)

• Builds quotidiens sur les feeds nuget

• Fun!

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Actuellement il n’y a que xUnit avec un runtime dédié pour KRE

Utilisez kmon pour avoir un file watchter et relancer automatiquement vostests (valable aussi pour le serveur web)

Tests

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Rui Carvalho@rhwy

http://ncrafts.io

Paul Cociuba@paulcociuba

Questions ?https://github.com/rhwy/Asp

Net5Mvc6TalksCode

https://github.com/pcociuba/T

echDaysDemo

[email protected]

Bonus Content

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Ajoutez un fichier NuGet.config dans votre projetpour overrider les sources par défaut du système

tech.days 2015#mstechdaysASP.NET MVC6 @rhwy & @paulcociuba

Ajoutez simplement un log de requêtes dans la console:

Vous pouvez tout faire simplement dans le pipeline de la requête (n’utilisez des libs/frameworks que si vraimentnécessaire )

© 2015 Microsoft Corporation. All rights reserved.

tech days•

2015

#mstechdays techdays.microsoft.fr