asp.net mvc 5 et web api 2
DESCRIPTION
La plateforme Web Microsoft ne cesse d'évoluer. La sortie de Visual Studio 2013 s'accompagne d'ASP.NET MVC5 et Web API 2, qui apportent chacunes leurs lots de nouveautés ! Dans cette session, vous découvrirez toutes les nouvelles APIs et nouveaux outils pour développer des applications Web avec Visual Studio 2013. Speakers : Simon Ferquel (Infinite Square), Julien Corioland (Infinite Square)TRANSCRIPT
![Page 1: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/1.jpg)
![Page 2: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/2.jpg)
ASP.NET MVC 5 et Web API 2
Julien CORIOLANDTech Lead Web &
CloudInfinite Square
@beedoo
http://www.infinitesquare.com http://blogs.infinitesquare.com
Simon FERQUELSenior DeveloperInfinite Square@sferquel
![Page 3: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/3.jpg)
#mstechdays
• Société de conseil, expertise, réalisation, formation, spécialisée dans le développement d’applications logicielles innovantes sur les technologies Microsoft
• 100% des consultants certifiés Microsoft, parmi lesquels 10 MVP et 2 Nokia Champions
• GOLD Certified Partner sur 5 domaines de compétences
• Centre de formation agrée
Infinite Square – stand 19
![Page 4: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/4.jpg)
#mstechdays
• Quelques rappels rapides
• Quoi de neuf pour ASP.NET MVC 5(.1) et Web API 2(.1) : plein de démos !
• Le futur est dans OWIN !
• Conclusion / Questions
Agenda
![Page 5: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/5.jpg)
#mstechdays
QUELQUES RAPPELS
Parce que revoir les bases, ça ne fait jamais de mal !
![Page 6: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/6.jpg)
#mstechdays
ASP.NET MVC
Contrôleur
Modèle
Vue
ModelBinders
ViewModels
Annotations
Validators
HTML Helpers
Razor / ASPX
jQuery
Action Results
Actions
Filters
Routes
![Page 7: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/7.jpg)
#mstechdays
ASP.NET Web API
Réception d’une requête HTTP (GET, POST, PUT, DELETE, HEAD)
Résolution de la route / Invocation de l’action du contrôleur
Content-Negociation (Accept HTTP Header)
Renvoi de la réponse dans le bon format
![Page 8: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/8.jpg)
#mstechdays
QUOI DE NEUF DANS ASP.NET MVC 5 ET WEB API 2A chaque nouveauté sa démo !
![Page 9: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/9.jpg)
#mstechdays
One ASP.NET
ASP.NET
MVCWeb
PagesWeb
FormsSPA
Web API
SignalR
Sites Services
![Page 10: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/10.jpg)
#mstechdays
One ASP.NET dans Visual Studio 2013
![Page 11: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/11.jpg)
démo
#mstechdays
ONE ASP.NET & VISUAL STUDIO 2013
![Page 12: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/12.jpg)
#mstechdays
ASP.NET Identity• Nouveau système de memberships
d’ASP.NET
• Authentification basée sur des claims
• Utilise des middlewares d’authentification OWIN
![Page 13: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/13.jpg)
#mstechdays
ASP.NET Identity• Nouveau schéma
de stockage des utilisateurs
– Multi-logins
– Microsoft propose une implémentation EF Code First
– Totalement personnalisable
![Page 14: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/14.jpg)
démo
#mstechdays
ASP.NET IDENTITY
![Page 15: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/15.jpg)
#mstechdays
Attribute Routing• Configuration des routes à
l’aide d’attributs– Directement sur les contrôleurs /
actions– Evalués et mis en cache dans la table
de route au démarrage de l’application
• Pas de limitation par rapport à la définition des routes « traditionnelles »
• On peut mixer les deux
• Marche aussi avec Web API 2 !
![Page 16: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/16.jpg)
démo
#mstechdays
ATTRIBUTES ROUTING
![Page 17: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/17.jpg)
#mstechdays
Web API Batching• Permet de combiner plusieurs opérations
dans une seule requête http POST
– Réduction du trafic réseau– Récupération de données plus adaptés aux interfaces
modernes / riches
![Page 18: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/18.jpg)
démo
#mstechdays
WEB API BATCHING
![Page 19: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/19.jpg)
#mstechdays
Web API OData• Permet d’exposer une Web API via OData, à
l’aide d’un simple attribut « Queryable »
• Quelques nouveautés avec Web API 2 :– $select, $expand, $batch, $value– Possibilité d’étendre les formatters Odata– Possibilité d’utiliser un modèle de données déjà existant
![Page 20: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/20.jpg)
démo
#mstechdays
WEB API ODATA
![Page 21: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/21.jpg)
#mstechdays
OWIN : c’est quoi ?• Open Web INterface• Abstraction du serveur webASP.Net
Web APIASP.Net
MVCSignalR ...
OWIN+ middlewares…
IISHttp
Listener
Unit test host
…
![Page 22: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/22.jpg)
#mstechdays
OWIN : et les middlewares, c’est quoi ?• Composants techniques
– Logs– Authentification– Compression– Rewriting…
• Compatibles avec n’importe quel host (IIS, Self Host, custom…)
• Compatibles avec n’importe quel Framework applicatif supportant Owin (ASP.Net WebForm, Web API, MVC, NancyFX, Signalr…)
• Out of the box:– OAuth2– CookieAuth– Facebook– Google…
![Page 23: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/23.jpg)
démo
#mstechdays
OWIN : MIDDLEWARE DE LOGS ET AUTHENTIFICATION WEB API
![Page 24: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/24.jpg)
#mstechdays
OWIN-host alternatifs ?• OWIN fournit des interfaces pour créer son
propre host• Microsoft en fournit 3 :– Host IIS
• Hébergement web classique
– http listener• Embarqué, agent local, communication inter-processus
– Unit test• Faciliter les tests unitaires
![Page 25: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/25.jpg)
démo
#mstechdays
OWIN ET TESTS UNITAIRES
![Page 26: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/26.jpg)
#mstechdays
Petit bonus : MVC 5.1 / Web API 2.1• Support des énumérations dans les vues
– Display Name, DropDownListFor
• Unobtrusive validation pour MaxLength / MinLength
• Possibilité de passer des html attributs aux EditorFor (enfin! )
• MediaTypeFormatter pour BSON
![Page 27: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/27.jpg)
#mstechdays
Conclusion / Questions• Pas forcément énormément de nouveauté en terme
de fonctionnalités dans ASP.NET MVC 5 et Web API 2, mais…
• Enormément de nouveautés « transverses » avec OWIN, ASP.NET Identity et surtout : « One ASP.NET ».
• Code source & démos : https://github.com/simonferquel/techdays-paris-2014-mvc-webapi
• A vos questions !
![Page 28: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/28.jpg)
#mstechdays
Depuis votre smartphone sur :http://notes.mstechdays.fr
De nombreux lots à gagner toute les heures !!!Claviers, souris et jeux Microsoft…
Merci de nous aider à améliorer les Techdays !
Donnez votre avis !
![Page 29: ASP.NET MVC 5 et Web API 2](https://reader036.vdocuments.mx/reader036/viewer/2022081413/547fb476b4af9f5a528b4813/html5/thumbnails/29.jpg)
© 2014 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries.The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Digital is business