SlideShare a Scribd company logo
18 NOVEMBRE 2016
ASP.NET Core essentials
Andrea Saltarello
Solution Architect @ Managed Designs
https://twitter.com/andysal74
Talk.About();
• Anatomia di una applicazione ASP.NET Core
• Architettura di ASP.NET Core
• Cenni a MVC Core
P.S.: demo scaricabili qui: http://nsk.codeplex.com (appena mi
convertono il progetto da TFSVC a Git )
Anatomia di una applicazione ASP.NET Core
Una applicazione ASP.NET Core:
1. Può «girare» sia su .NET Core sia su .NET Framework
2. Limitatamente a .NET Core, può essere sviluppata su: Linux, macOS,
Windows
3. È una «normale» applicazione console “ospitata” da un server e
configurata mediante codice
ASP.NET Core at a glance
La Dev story: gli editor
Per sviluppare, abbiamo varie opzioni:
1. Supporto per: Sublime, Atom, Emacs, Vim e Brackets
2. Solo supporto xproj
3. macOS: solo csproj; Windows: xproj per v2015, csproj per v2017
Linux macOS Windows
CLI + OmniSharp¹ solo .NET Core solo .NET Core solo .NET Core
Xamarin Studio solo .NET Core²
Visual Studio Code solo .NET Core solo .NET Core X
Visual Studio³ solo .NET Core X
La Dev story: il deploy
(ASP).NET Core è distribuito in due versioni:
1. LTS: supportate per 3 anni *o* per 1 anno dopo il rilascio della LTS successiva.
L’attuate versione LTS è la 1.0.1
2. Current: supportate, all’interno della corrispettiva LTS, per 3 mesi a partire dal
rilascio della «current» successiva
.NET Core only:
• il deploy permette sia di usare l’installazione del FX a livello di macchina, sia una
locale alla applicazione
• non esistono drop release, tutte le versioni sono installate side-by-side
[ https://www.microsoft.com/net/core/support ]
1 - demo
Dev Story
Una «normale» applicazione Console…
…ospitata da un server…
Sono i «container»: ASP.NET Core fornisce i seguenti:
• Kestrel (managed, xplat)
• WebListener (httpsys, 1.1+)
…e configurata mediante codice
Per configurare una applicazione usiamo:
• project.json per specificare le reference, da VS 2017/Mac GA in poi ye
olde csproj
• Startup.cs (o omologa) per configurare i middleware
1. ConfigureServices()
2. Configure()
• [OPT] appsettings.json per «informazioni» di configurazione
• ASPNETCORE_ENVIRONMENT
Middleware
Sono funzioni che:
• implementano la delegate RequestDelegate
• vengono aggiunti alla request pipeline di ASP.NET Core
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
app.Run(async (context) =>
{
await context.Response.WriteAsync("Hello World!");
});
}
2 - demo
Middleware
Middleware
ASP.NET Core fornisce out of the box alcuni middleware, tra i quali:
• Identity
• MVC
• ResponseCaching (1.1+)
• ResponseCompression (1.1+)
• Rewrite (1.1+)
Per convenzione, vengono registrati in ConfigureServices ed attivati in
Configure
[ https://blogs.msdn.microsoft.com/webdev/2016/11/16/announcing-asp-net-core-1-1/ ]
ConfigureServices(), parte 2
La registrazione dei middleware serve, sostanzialmente, a configurarne le
dipendenze (nel senso IoC) tipicamente mediante extension method ad hoc (es:
AddMvc, AddIdentity, …)
E’ basata su un IoC container built-in, che permette di:
1. Registrare dei tipi indicando lo scope delle istanze da generare:
• AddInstance
• AddSingleton
• AddScoped
• AddTransient
2. Esporre le dipendenze di:
• Ctor
• Parametri action: FromServicesAttribute
• View: @inject
E’ possibile sostituire il container built in con uno di terze parti:
https://github.com/aspnet/DependencyInjection/blob/dev/README.md
MVC
ASP.NET MVC Core
E’ il middleware fornito out of the box da ASP.NET Core per implementare
applicazioni basate sulla variante Model 2 del pattern MVC (quella di Struts,
Rails, Monorail, …)
API molto simile a MVC 5 di ASP.NET 4, ma con alcune differenze strutturali:
• pipeline MVC-WebAPI integrata
• supporto a controller POCO
• dependency Resolver Injection
Per vederlo in azione, guardare qui:
http://www.ugidotnet.org/video/189329326/NET05--ASP-NET-MVC-Core-1
Grazie!
Contatti:
• https://twitter.com/andysal74
• http://blogs.ugidotnet.org/pape
• andrea@ugidotnet.org
Thank you! Questions?
https://twitter.com/ugidotnet

More Related Content

Viewers also liked

.NET Core on Mac
.NET Core on Mac.NET Core on Mac
.NET Core on Mac
Melania Andrisan (Danciu)
 
Idiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSIdiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRS
Andrea Saltarello
 
The Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event SourcingThe Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event Sourcing
Andrea Saltarello
 
Ask The Expert - Typescript: A stitch in time saves nine
Ask The Expert - Typescript: A stitch in time saves nineAsk The Expert - Typescript: A stitch in time saves nine
Ask The Expert - Typescript: A stitch in time saves nine
Gianluca Carucci
 
Architecting an ASP.NET MVC Solution
Architecting an ASP.NET MVC SolutionArchitecting an ASP.NET MVC Solution
Architecting an ASP.NET MVC Solution
Andrea Saltarello
 
How I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven DesignHow I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven DesignAndrea Saltarello
 
Implementing Event Sourcing in .NET
Implementing Event Sourcing in .NETImplementing Event Sourcing in .NET
Implementing Event Sourcing in .NET
Andrea Saltarello
 
Introduction to .NET Core & ASP.NET Core MVC
Introduction to .NET Core & ASP.NET Core MVCIntroduction to .NET Core & ASP.NET Core MVC
Introduction to .NET Core & ASP.NET Core MVC
Saineshwar bageri
 
Introduction to .NET Core
Introduction to .NET CoreIntroduction to .NET Core
Introduction to .NET Core
Marco Parenzan
 
ASP .NET Core hands-on
ASP .NET Core hands-onASP .NET Core hands-on
ASP .NET Core hands-on
ugidotnet
 
.NET Core, ASP.NET Core e Linux per il Mobile
.NET Core, ASP.NET Core e Linux per il Mobile.NET Core, ASP.NET Core e Linux per il Mobile
.NET Core, ASP.NET Core e Linux per il Mobile
Pietro Libro
 

Viewers also liked (11)

.NET Core on Mac
.NET Core on Mac.NET Core on Mac
.NET Core on Mac
 
Idiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSIdiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRS
 
The Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event SourcingThe Fine Art of Time Travelling: implementing Event Sourcing
The Fine Art of Time Travelling: implementing Event Sourcing
 
Ask The Expert - Typescript: A stitch in time saves nine
Ask The Expert - Typescript: A stitch in time saves nineAsk The Expert - Typescript: A stitch in time saves nine
Ask The Expert - Typescript: A stitch in time saves nine
 
Architecting an ASP.NET MVC Solution
Architecting an ASP.NET MVC SolutionArchitecting an ASP.NET MVC Solution
Architecting an ASP.NET MVC Solution
 
How I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven DesignHow I did it (in .NET): idiomatic Domain Driven Design
How I did it (in .NET): idiomatic Domain Driven Design
 
Implementing Event Sourcing in .NET
Implementing Event Sourcing in .NETImplementing Event Sourcing in .NET
Implementing Event Sourcing in .NET
 
Introduction to .NET Core & ASP.NET Core MVC
Introduction to .NET Core & ASP.NET Core MVCIntroduction to .NET Core & ASP.NET Core MVC
Introduction to .NET Core & ASP.NET Core MVC
 
Introduction to .NET Core
Introduction to .NET CoreIntroduction to .NET Core
Introduction to .NET Core
 
ASP .NET Core hands-on
ASP .NET Core hands-onASP .NET Core hands-on
ASP .NET Core hands-on
 
.NET Core, ASP.NET Core e Linux per il Mobile
.NET Core, ASP.NET Core e Linux per il Mobile.NET Core, ASP.NET Core e Linux per il Mobile
.NET Core, ASP.NET Core e Linux per il Mobile
 

Similar to ASP.NET Core essentials

Meetup DotNetCode Settembre 2018 - ASP.NET Core 2.1
Meetup DotNetCode Settembre 2018 - ASP.NET Core 2.1Meetup DotNetCode Settembre 2018 - ASP.NET Core 2.1
Meetup DotNetCode Settembre 2018 - ASP.NET Core 2.1
dotnetcode
 
Introduzione ad ASP.NET Core
Introduzione ad ASP.NET CoreIntroduzione ad ASP.NET Core
Introduzione ad ASP.NET Core
Andrea Dottor
 
Alessandro Forte - ASP.Net 4.0
Alessandro Forte - ASP.Net 4.0Alessandro Forte - ASP.Net 4.0
Alessandro Forte - ASP.Net 4.0
Alessandro Forte
 
Oltre il Worker Role, da Serverless computing a VM Scale Set
Oltre il Worker Role, da Serverless computing a VM Scale SetOltre il Worker Role, da Serverless computing a VM Scale Set
Oltre il Worker Role, da Serverless computing a VM Scale Set
Vito Flavio Lorusso
 
ASP.NET Core Services e Linux per il Mobile - Pietro Libro - Codemotion Rome...
ASP.NET Core Services e Linux per il Mobile  - Pietro Libro - Codemotion Rome...ASP.NET Core Services e Linux per il Mobile  - Pietro Libro - Codemotion Rome...
ASP.NET Core Services e Linux per il Mobile - Pietro Libro - Codemotion Rome...
Codemotion
 
ASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuroASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuro
Andrea Dottor
 
Node.js - Server Side Javascript
Node.js - Server Side JavascriptNode.js - Server Side Javascript
Node.js - Server Side Javascript
Matteo Napolitano
 
ASP.NET Core Web Framework Benchmarks
ASP.NET Core Web Framework BenchmarksASP.NET Core Web Framework Benchmarks
ASP.NET Core Web Framework Benchmarks
Nicolò Carandini
 
Back to the Future: Migrare da WebForm ad ASP.NET Core gradualmente
Back to the Future: Migrare da WebForm ad ASP.NET Core gradualmente Back to the Future: Migrare da WebForm ad ASP.NET Core gradualmente
Back to the Future: Migrare da WebForm ad ASP.NET Core gradualmente
Andrea Dottor
 
Le novita di visual studio 2012
Le novita di visual studio 2012Le novita di visual studio 2012
Le novita di visual studio 2012Crismer La Pignola
 
Sviluppare Azure Web Apps
Sviluppare Azure Web AppsSviluppare Azure Web Apps
Sviluppare Azure Web Apps
Andrea Dottor
 
Meetup ASP.NET Core 2 e Docker
Meetup ASP.NET Core 2 e Docker Meetup ASP.NET Core 2 e Docker
Meetup ASP.NET Core 2 e Docker
dotnetcode
 
ASP.NET Core 2 e Docker
ASP.NET Core 2 e DockerASP.NET Core 2 e Docker
ASP.NET Core 2 e Docker
Luca Congiu
 
Novità di Asp.Net 4.0
Novità di Asp.Net 4.0Novità di Asp.Net 4.0
Novità di Asp.Net 4.0
Gian Maria Ricci
 
High specialized vm on open stack cloud
High specialized vm on open stack cloudHigh specialized vm on open stack cloud
High specialized vm on open stack cloud
Gabriele Baldoni
 
Meetup ASP.NET Core Angular
Meetup ASP.NET Core AngularMeetup ASP.NET Core Angular
Meetup ASP.NET Core Angular
dotnetcode
 
Creazione componenti con Vue js
Creazione componenti con Vue jsCreazione componenti con Vue js
Creazione componenti con Vue js
Gianfranco Castro
 
VS Package @ CD2008
VS Package @ CD2008VS Package @ CD2008
VS Package @ CD2008
Mauro Servienti
 
Meetup ASP.NET Core e Kubernetes
Meetup ASP.NET Core e KubernetesMeetup ASP.NET Core e Kubernetes
Meetup ASP.NET Core e Kubernetes
dotnetcode
 

Similar to ASP.NET Core essentials (20)

Meetup DotNetCode Settembre 2018 - ASP.NET Core 2.1
Meetup DotNetCode Settembre 2018 - ASP.NET Core 2.1Meetup DotNetCode Settembre 2018 - ASP.NET Core 2.1
Meetup DotNetCode Settembre 2018 - ASP.NET Core 2.1
 
Introduzione ad ASP.NET Core
Introduzione ad ASP.NET CoreIntroduzione ad ASP.NET Core
Introduzione ad ASP.NET Core
 
Alessandro Forte - ASP.Net 4.0
Alessandro Forte - ASP.Net 4.0Alessandro Forte - ASP.Net 4.0
Alessandro Forte - ASP.Net 4.0
 
Oltre il Worker Role, da Serverless computing a VM Scale Set
Oltre il Worker Role, da Serverless computing a VM Scale SetOltre il Worker Role, da Serverless computing a VM Scale Set
Oltre il Worker Role, da Serverless computing a VM Scale Set
 
ASP.NET Core Services e Linux per il Mobile - Pietro Libro - Codemotion Rome...
ASP.NET Core Services e Linux per il Mobile  - Pietro Libro - Codemotion Rome...ASP.NET Core Services e Linux per il Mobile  - Pietro Libro - Codemotion Rome...
ASP.NET Core Services e Linux per il Mobile - Pietro Libro - Codemotion Rome...
 
ASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuroASP.NET MVC 6 - uno sguardo al futuro
ASP.NET MVC 6 - uno sguardo al futuro
 
Node.js - Server Side Javascript
Node.js - Server Side JavascriptNode.js - Server Side Javascript
Node.js - Server Side Javascript
 
ASP.NET Core Web Framework Benchmarks
ASP.NET Core Web Framework BenchmarksASP.NET Core Web Framework Benchmarks
ASP.NET Core Web Framework Benchmarks
 
Web frameworks
Web frameworksWeb frameworks
Web frameworks
 
Back to the Future: Migrare da WebForm ad ASP.NET Core gradualmente
Back to the Future: Migrare da WebForm ad ASP.NET Core gradualmente Back to the Future: Migrare da WebForm ad ASP.NET Core gradualmente
Back to the Future: Migrare da WebForm ad ASP.NET Core gradualmente
 
Le novita di visual studio 2012
Le novita di visual studio 2012Le novita di visual studio 2012
Le novita di visual studio 2012
 
Sviluppare Azure Web Apps
Sviluppare Azure Web AppsSviluppare Azure Web Apps
Sviluppare Azure Web Apps
 
Meetup ASP.NET Core 2 e Docker
Meetup ASP.NET Core 2 e Docker Meetup ASP.NET Core 2 e Docker
Meetup ASP.NET Core 2 e Docker
 
ASP.NET Core 2 e Docker
ASP.NET Core 2 e DockerASP.NET Core 2 e Docker
ASP.NET Core 2 e Docker
 
Novità di Asp.Net 4.0
Novità di Asp.Net 4.0Novità di Asp.Net 4.0
Novità di Asp.Net 4.0
 
High specialized vm on open stack cloud
High specialized vm on open stack cloudHigh specialized vm on open stack cloud
High specialized vm on open stack cloud
 
Meetup ASP.NET Core Angular
Meetup ASP.NET Core AngularMeetup ASP.NET Core Angular
Meetup ASP.NET Core Angular
 
Creazione componenti con Vue js
Creazione componenti con Vue jsCreazione componenti con Vue js
Creazione componenti con Vue js
 
VS Package @ CD2008
VS Package @ CD2008VS Package @ CD2008
VS Package @ CD2008
 
Meetup ASP.NET Core e Kubernetes
Meetup ASP.NET Core e KubernetesMeetup ASP.NET Core e Kubernetes
Meetup ASP.NET Core e Kubernetes
 

More from Andrea Saltarello

Layered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSLayered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRS
Andrea Saltarello
 
ASP.NET MVC: Full Throttle
ASP.NET MVC: Full ThrottleASP.NET MVC: Full Throttle
ASP.NET MVC: Full Throttle
Andrea Saltarello
 
Code Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled RepositoryCode Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled Repository
Andrea Saltarello
 
Build a LINQ-enabled Repository
Build a LINQ-enabled RepositoryBuild a LINQ-enabled Repository
Build a LINQ-enabled Repository
Andrea Saltarello
 
Layered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDDLayered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDD
Andrea Saltarello
 
From relational data to object spaces
From relational data to object spacesFrom relational data to object spaces
From relational data to object spaces
Andrea Saltarello
 

More from Andrea Saltarello (7)

Layered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSLayered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRS
 
ASP.NET MVC: Full Throttle
ASP.NET MVC: Full ThrottleASP.NET MVC: Full Throttle
ASP.NET MVC: Full Throttle
 
Code Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled RepositoryCode Contracts and Generics: implementing a LINQ-enabled Repository
Code Contracts and Generics: implementing a LINQ-enabled Repository
 
Build a LINQ-enabled Repository
Build a LINQ-enabled RepositoryBuild a LINQ-enabled Repository
Build a LINQ-enabled Repository
 
Layered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDDLayered Expression Trees: una terza via (idiomatica) verso il DDD
Layered Expression Trees: una terza via (idiomatica) verso il DDD
 
From relational data to object spaces
From relational data to object spacesFrom relational data to object spaces
From relational data to object spaces
 
MVC2: non solo tecnologia
MVC2: non solo tecnologiaMVC2: non solo tecnologia
MVC2: non solo tecnologia
 

ASP.NET Core essentials

  • 1. 18 NOVEMBRE 2016 ASP.NET Core essentials Andrea Saltarello Solution Architect @ Managed Designs https://twitter.com/andysal74
  • 2. Talk.About(); • Anatomia di una applicazione ASP.NET Core • Architettura di ASP.NET Core • Cenni a MVC Core P.S.: demo scaricabili qui: http://nsk.codeplex.com (appena mi convertono il progetto da TFSVC a Git )
  • 3. Anatomia di una applicazione ASP.NET Core Una applicazione ASP.NET Core: 1. Può «girare» sia su .NET Core sia su .NET Framework 2. Limitatamente a .NET Core, può essere sviluppata su: Linux, macOS, Windows 3. È una «normale» applicazione console “ospitata” da un server e configurata mediante codice
  • 4. ASP.NET Core at a glance
  • 5. La Dev story: gli editor Per sviluppare, abbiamo varie opzioni: 1. Supporto per: Sublime, Atom, Emacs, Vim e Brackets 2. Solo supporto xproj 3. macOS: solo csproj; Windows: xproj per v2015, csproj per v2017 Linux macOS Windows CLI + OmniSharp¹ solo .NET Core solo .NET Core solo .NET Core Xamarin Studio solo .NET Core² Visual Studio Code solo .NET Core solo .NET Core X Visual Studio³ solo .NET Core X
  • 6. La Dev story: il deploy (ASP).NET Core è distribuito in due versioni: 1. LTS: supportate per 3 anni *o* per 1 anno dopo il rilascio della LTS successiva. L’attuate versione LTS è la 1.0.1 2. Current: supportate, all’interno della corrispettiva LTS, per 3 mesi a partire dal rilascio della «current» successiva .NET Core only: • il deploy permette sia di usare l’installazione del FX a livello di macchina, sia una locale alla applicazione • non esistono drop release, tutte le versioni sono installate side-by-side [ https://www.microsoft.com/net/core/support ]
  • 7. 1 - demo Dev Story
  • 9. …ospitata da un server… Sono i «container»: ASP.NET Core fornisce i seguenti: • Kestrel (managed, xplat) • WebListener (httpsys, 1.1+)
  • 10. …e configurata mediante codice Per configurare una applicazione usiamo: • project.json per specificare le reference, da VS 2017/Mac GA in poi ye olde csproj • Startup.cs (o omologa) per configurare i middleware 1. ConfigureServices() 2. Configure() • [OPT] appsettings.json per «informazioni» di configurazione • ASPNETCORE_ENVIRONMENT
  • 11. Middleware Sono funzioni che: • implementano la delegate RequestDelegate • vengono aggiunti alla request pipeline di ASP.NET Core public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory) { app.Run(async (context) => { await context.Response.WriteAsync("Hello World!"); }); }
  • 13. Middleware ASP.NET Core fornisce out of the box alcuni middleware, tra i quali: • Identity • MVC • ResponseCaching (1.1+) • ResponseCompression (1.1+) • Rewrite (1.1+) Per convenzione, vengono registrati in ConfigureServices ed attivati in Configure [ https://blogs.msdn.microsoft.com/webdev/2016/11/16/announcing-asp-net-core-1-1/ ]
  • 14. ConfigureServices(), parte 2 La registrazione dei middleware serve, sostanzialmente, a configurarne le dipendenze (nel senso IoC) tipicamente mediante extension method ad hoc (es: AddMvc, AddIdentity, …) E’ basata su un IoC container built-in, che permette di: 1. Registrare dei tipi indicando lo scope delle istanze da generare: • AddInstance • AddSingleton • AddScoped • AddTransient 2. Esporre le dipendenze di: • Ctor • Parametri action: FromServicesAttribute • View: @inject E’ possibile sostituire il container built in con uno di terze parti: https://github.com/aspnet/DependencyInjection/blob/dev/README.md
  • 15. MVC
  • 16. ASP.NET MVC Core E’ il middleware fornito out of the box da ASP.NET Core per implementare applicazioni basate sulla variante Model 2 del pattern MVC (quella di Struts, Rails, Monorail, …) API molto simile a MVC 5 di ASP.NET 4, ma con alcune differenze strutturali: • pipeline MVC-WebAPI integrata • supporto a controller POCO • dependency Resolver Injection Per vederlo in azione, guardare qui: http://www.ugidotnet.org/video/189329326/NET05--ASP-NET-MVC-Core-1