SlideShare a Scribd company logo
1 of 29
ASP.NET MVC: non solo «tennologgia» Andrea Saltarello (Solution) Architect @ ManagedDesigns S.r.l. – http://www.manageddesigns.it andysal@gmail.com http://blogs.ugidotnet.org/pape http://twitter.com/andysal74 http://creativecommons.org/licenses/by-nc-nd/2.5/
Innanzitutto… Grazie,                                     ! 
Agenda #ifdef NIUBBO MVC 1-2-3 Controller->View View->Controller AspNetMvc.More();
ModelView Controller Formulato nel 1979 da TrygveReenskaug, membro del team Smalltalk @ Xerox PARC La prima motivazione di design è: Separare gli aspetti di presentazione da  quelli di dominio. E' la “radice concettuale” di tutti gli attuali pattern: Model ViewPresenter, Presenter-First, Passive View, Presentation Abstraction Control, Presentation ModelModelViewViewModel...
Model view controller Model StateQuery StateChange Change Notification View Controller View Selection User Gestures Method Invocations Events
MVC: falsi miti Lo scopo del Controller non è di separare la ViewdalModel.  La responsabilità del Controller è di fare damediatoretral'utente e l'applicazione, non tra la View e ilModel. Spessosiparla di MVC, ma siintendeModel 2
Model 2 In a Model 2 application, requests from the client browser are passed to the controller, which is a servlet. The controller decides which view (JSP) it will pass the request to. The view then invokes methods in a JavaBean (which may access a database) and returns the Response object to the Web container, which is then passed on to the client browser. [Wikipedia] Legenda: ,[object Object]
JSP->Controller->Page Controller [P of EAA, 333],[object Object]
Introduzione a ASP.NET MVC (2/4) http://host/webapp/Customer/Detail/1
Introduzione a ASP.NET MVC (3/4) http://host/webapp/Customer/Detail/1
Introduzione a ASP.NET MVC (4/4) http://host/webapp/Customer/Detail/1
Navigation Flow Le action restituiscono un valore di tipo ActionResult. “Pragmapolimorficamente” parlando: ,[object Object],PartialViewResult. Restituito dal metodoPartialView. ,[object Object]
RedirectResult. RestituitodalmetodoRedirect.
ContentResult. RestituitodalmetodoContent.
JsonResult. RestituitodalmetodoJson.
EmptyResult. Restituitodalle action chevoglianorestituire “null”.
YourOwnPersonalResult(semi-cit), restituito da una factory ad hoc,[object Object]
Dati: Controller->View Per trasferire dati dal controller alla view: ViewData YourView.Model=Presentation View Model
ASP.Net MVC
Dati: View->Controller Per trasferire dati dalla view al controller: Parametridella action (convention over configuration):  ognielemento in query string èmappatosu un parametroomonimo ognielemento del <form /> èmappatosu un parametroomonimo FormCollection >>>Model binding<<<
ASP.Net MVC
Data Entry Built in: Usare i metodi helper per definire i “campi” Taggareil ViewModel mediante DataAnnotations Ricordarsi Html.ValidationMessageFor<>() e/o Html.ValidationSummary() [Opzionale]Impostare .input-validation-error nel css [Opzionale]: EditorTemplates, DisplayTemplates
ASP.Net MVC
Data Entry <3 JQuery Client side validation Inclusione degli script JS <% Html.EnableClientSideValidation(); %> JQuery plug-in, es: JQuery UI (tab, datepicker, …) JQGrid Assert.IsTrueLove(EditorTemplates, JQuery)
ASP.Net MVC
AspNetMvc.More(); Esempi: [FX4 only]<%: … %> (equivalente a <% =Html.Encode(…) %>) IoC Custom ActionResult: Generare Thumbnail Generare Atom/RSS (http://www.ugidotnet.org/Article/Detail/280) “Componentization”: RenderPartial+RenderAction Test Aree
ASP.Net MVC
MVC @ ManagedDesigns In azienda usiamo il toolkit MVC dalle prime CTP della v1, ed abbiamo raggiunto una struttura «standardizzata» dei progetti: Model 3 LayeredExpressionTrees
MVC goes Model 3 Model 2 separa il Controller in: Front Controller Page Controller Model 3 separa il Model in: View Model: rappresenta i dati che la view si impegna a presentare all’utente Worker Service: è la façade che il page controller utilizza per produrre il View Model E’ il Single ResponsibilityPrinciple, baby!

More Related Content

Similar to MVC2: non solo tecnologia

Asp.NET MVC Framework
Asp.NET MVC FrameworkAsp.NET MVC Framework
Asp.NET MVC FrameworkDotNetMarche
 
Migliora il tuo codice con knockout.js
Migliora il tuo codice con knockout.jsMigliora il tuo codice con knockout.js
Migliora il tuo codice con knockout.jsAndrea Dottor
 
Asp.Net MVC 2 :: VS 2010 Community Tour
Asp.Net MVC 2 :: VS 2010 Community TourAsp.Net MVC 2 :: VS 2010 Community Tour
Asp.Net MVC 2 :: VS 2010 Community TourAndrea Balducci
 
Hands on MVC - Mastering the Web
Hands on MVC - Mastering the WebHands on MVC - Mastering the Web
Hands on MVC - Mastering the WebClaudio Gandelli
 
Asp.net 4 Community Tour VS2010
Asp.net 4 Community Tour VS2010Asp.net 4 Community Tour VS2010
Asp.net 4 Community Tour VS2010Fabrizio Bernabei
 
Alessandro Forte - MVP vs MVC
Alessandro Forte - MVP vs MVCAlessandro Forte - MVP vs MVC
Alessandro Forte - MVP vs MVCAlessandro Forte
 
Dal RenderFragment ai Generics, tips for Blazor developers
Dal RenderFragment ai Generics, tips for Blazor developersDal RenderFragment ai Generics, tips for Blazor developers
Dal RenderFragment ai Generics, tips for Blazor developersAndrea Dottor
 
Fe02 ria con breeze e knockout
Fe02   ria con breeze e knockoutFe02   ria con breeze e knockout
Fe02 ria con breeze e knockoutDotNetCampus
 
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 futuroAndrea Dottor
 
Zend Framework Workshop Parte2
Zend Framework Workshop Parte2Zend Framework Workshop Parte2
Zend Framework Workshop Parte2massimiliano.wosz
 
Fare con Zend Framework 2 ciò che facevo con ZF1
Fare con Zend Framework 2 ciò che facevo con ZF1Fare con Zend Framework 2 ciò che facevo con ZF1
Fare con Zend Framework 2 ciò che facevo con ZF1Steve Maraspin
 
Applicazioni web con Asp.Net MVC 6
Applicazioni web con Asp.Net MVC 6Applicazioni web con Asp.Net MVC 6
Applicazioni web con Asp.Net MVC 6Michele Aponte
 
Integrazione continua con TFS Build
Integrazione continua con TFS BuildIntegrazione continua con TFS Build
Integrazione continua con TFS BuildGian Maria Ricci
 
Niccolò Becchi: Introduzione a GWT
Niccolò Becchi: Introduzione a GWTNiccolò Becchi: Introduzione a GWT
Niccolò Becchi: Introduzione a GWTfirenze-gtug
 
Introduzione ai componenti in Angular 4
Introduzione ai componenti in Angular 4Introduzione ai componenti in Angular 4
Introduzione ai componenti in Angular 4Giovanni Buffa
 

Similar to MVC2: non solo tecnologia (20)

Asp.NET MVC Framework
Asp.NET MVC FrameworkAsp.NET MVC Framework
Asp.NET MVC Framework
 
Migliora il tuo codice con knockout.js
Migliora il tuo codice con knockout.jsMigliora il tuo codice con knockout.js
Migliora il tuo codice con knockout.js
 
Asp.Net MVC 2 :: VS 2010 Community Tour
Asp.Net MVC 2 :: VS 2010 Community TourAsp.Net MVC 2 :: VS 2010 Community Tour
Asp.Net MVC 2 :: VS 2010 Community Tour
 
Hands on MVC - Mastering the Web
Hands on MVC - Mastering the WebHands on MVC - Mastering the Web
Hands on MVC - Mastering the Web
 
Asp.net 4 Community Tour VS2010
Asp.net 4 Community Tour VS2010Asp.net 4 Community Tour VS2010
Asp.net 4 Community Tour VS2010
 
Alessandro Forte - MVP vs MVC
Alessandro Forte - MVP vs MVCAlessandro Forte - MVP vs MVC
Alessandro Forte - MVP vs MVC
 
MVC and Struts 1
MVC and Struts 1MVC and Struts 1
MVC and Struts 1
 
Novità di Asp.Net 4.0
Novità di Asp.Net 4.0Novità di Asp.Net 4.0
Novità di Asp.Net 4.0
 
Dal RenderFragment ai Generics, tips for Blazor developers
Dal RenderFragment ai Generics, tips for Blazor developersDal RenderFragment ai Generics, tips for Blazor developers
Dal RenderFragment ai Generics, tips for Blazor developers
 
Fe02 ria con breeze e knockout
Fe02   ria con breeze e knockoutFe02   ria con breeze e knockout
Fe02 ria con breeze e knockout
 
AngularJS-Intro
AngularJS-IntroAngularJS-Intro
AngularJS-Intro
 
Introduzione a Struts
Introduzione a StrutsIntroduzione a Struts
Introduzione a Struts
 
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
 
Zend Framework Workshop Parte2
Zend Framework Workshop Parte2Zend Framework Workshop Parte2
Zend Framework Workshop Parte2
 
Zendframework Parte2
Zendframework    Parte2Zendframework    Parte2
Zendframework Parte2
 
Fare con Zend Framework 2 ciò che facevo con ZF1
Fare con Zend Framework 2 ciò che facevo con ZF1Fare con Zend Framework 2 ciò che facevo con ZF1
Fare con Zend Framework 2 ciò che facevo con ZF1
 
Applicazioni web con Asp.Net MVC 6
Applicazioni web con Asp.Net MVC 6Applicazioni web con Asp.Net MVC 6
Applicazioni web con Asp.Net MVC 6
 
Integrazione continua con TFS Build
Integrazione continua con TFS BuildIntegrazione continua con TFS Build
Integrazione continua con TFS Build
 
Niccolò Becchi: Introduzione a GWT
Niccolò Becchi: Introduzione a GWTNiccolò Becchi: Introduzione a GWT
Niccolò Becchi: Introduzione a GWT
 
Introduzione ai componenti in Angular 4
Introduzione ai componenti in Angular 4Introduzione ai componenti in Angular 4
Introduzione ai componenti in Angular 4
 

More from Andrea Saltarello

Da Rotor a .NET Core ed indietro: Microsoft &lt;3 Open Source
Da Rotor a .NET Core ed indietro: Microsoft &lt;3 Open SourceDa Rotor a .NET Core ed indietro: Microsoft &lt;3 Open Source
Da Rotor a .NET Core ed indietro: Microsoft &lt;3 Open SourceAndrea 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 SourcingAndrea Saltarello
 
Implementing Event Sourcing in .NET
Implementing Event Sourcing in .NETImplementing Event Sourcing in .NET
Implementing Event Sourcing in .NETAndrea Saltarello
 
Idiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSIdiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSAndrea Saltarello
 
Architecting an ASP.NET MVC Solution
Architecting an ASP.NET MVC SolutionArchitecting an ASP.NET MVC Solution
Architecting an ASP.NET MVC SolutionAndrea Saltarello
 
Never Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven DesignNever Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven DesignAndrea Saltarello
 
Layered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSLayered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSAndrea 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
 
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 RepositoryAndrea Saltarello
 
Idiomatic Domain Driven Design
Idiomatic Domain Driven DesignIdiomatic Domain Driven Design
Idiomatic Domain Driven DesignAndrea Saltarello
 
Build a LINQ-enabled Repository
Build a LINQ-enabled RepositoryBuild a LINQ-enabled Repository
Build a LINQ-enabled RepositoryAndrea 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 DDDAndrea Saltarello
 
From relational data to object spaces
From relational data to object spacesFrom relational data to object spaces
From relational data to object spacesAndrea Saltarello
 

More from Andrea Saltarello (14)

Da Rotor a .NET Core ed indietro: Microsoft &lt;3 Open Source
Da Rotor a .NET Core ed indietro: Microsoft &lt;3 Open SourceDa Rotor a .NET Core ed indietro: Microsoft &lt;3 Open Source
Da Rotor a .NET Core ed indietro: Microsoft &lt;3 Open Source
 
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
 
ASP.NET Core essentials
ASP.NET Core essentialsASP.NET Core essentials
ASP.NET Core essentials
 
Implementing Event Sourcing in .NET
Implementing Event Sourcing in .NETImplementing Event Sourcing in .NET
Implementing Event Sourcing in .NET
 
Idiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRSIdiomatic Domain Driven Design: implementing CQRS
Idiomatic Domain Driven Design: implementing CQRS
 
Architecting an ASP.NET MVC Solution
Architecting an ASP.NET MVC SolutionArchitecting an ASP.NET MVC Solution
Architecting an ASP.NET MVC Solution
 
Never Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven DesignNever Mind the Bollocks: here's the Domain Driven Design
Never Mind the Bollocks: here's the Domain Driven Design
 
Layered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRSLayered Expression Trees feat. CQRS
Layered Expression Trees feat. CQRS
 
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
 
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
 
Idiomatic Domain Driven Design
Idiomatic Domain Driven DesignIdiomatic Domain Driven Design
Idiomatic Domain Driven Design
 
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
 

Recently uploaded

Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...Associazione Digital Days
 
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”Associazione Digital Days
 
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...Associazione Digital Days
 
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...Associazione Digital Days
 
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...Associazione Digital Days
 
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...Associazione Digital Days
 
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...Associazione Digital Days
 
ScrapeGraphAI: a new way to scrape context with AI
ScrapeGraphAI: a new way to scrape context with AIScrapeGraphAI: a new way to scrape context with AI
ScrapeGraphAI: a new way to scrape context with AIinfogdgmi
 
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...Associazione Digital Days
 

Recently uploaded (9)

Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
Gabriele Mittica, CEO @Corley Cloud – “Come creare un’azienda “nativa in clou...
 
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
Edoardo Di Pietro – “Virtual Influencer vs Umano: Rubiamo il lavoro all’AI”
 
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
Alessandro Nasi, COO @Djungle Studio – “Cosa delegheresti alla copia di te st...
 
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
Alessio Mazzotti, Aaron Brancotti; Writer, Screenwriter, Director, UX, Autore...
 
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
Luigi Di Carlo, CEO & Founder @Evometrika srl – “Ruolo della computer vision ...
 
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
Mael Chiabrera, Software Developer; Viola Bongini, Digital Experience Designe...
 
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
Daniele Lunassi, CEO & Head of Design @Eye Studios – “Creare prodotti e servi...
 
ScrapeGraphAI: a new way to scrape context with AI
ScrapeGraphAI: a new way to scrape context with AIScrapeGraphAI: a new way to scrape context with AI
ScrapeGraphAI: a new way to scrape context with AI
 
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
Federico Bottino, Lead Venture Builder – “Riflessioni sull’Innovazione: La Cu...
 

MVC2: non solo tecnologia

  • 1. ASP.NET MVC: non solo «tennologgia» Andrea Saltarello (Solution) Architect @ ManagedDesigns S.r.l. – http://www.manageddesigns.it andysal@gmail.com http://blogs.ugidotnet.org/pape http://twitter.com/andysal74 http://creativecommons.org/licenses/by-nc-nd/2.5/
  • 3. Agenda #ifdef NIUBBO MVC 1-2-3 Controller->View View->Controller AspNetMvc.More();
  • 4. ModelView Controller Formulato nel 1979 da TrygveReenskaug, membro del team Smalltalk @ Xerox PARC La prima motivazione di design è: Separare gli aspetti di presentazione da quelli di dominio. E' la “radice concettuale” di tutti gli attuali pattern: Model ViewPresenter, Presenter-First, Passive View, Presentation Abstraction Control, Presentation ModelModelViewViewModel...
  • 5. Model view controller Model StateQuery StateChange Change Notification View Controller View Selection User Gestures Method Invocations Events
  • 6. MVC: falsi miti Lo scopo del Controller non è di separare la ViewdalModel. La responsabilità del Controller è di fare damediatoretral'utente e l'applicazione, non tra la View e ilModel. Spessosiparla di MVC, ma siintendeModel 2
  • 7.
  • 8.
  • 9. Introduzione a ASP.NET MVC (2/4) http://host/webapp/Customer/Detail/1
  • 10. Introduzione a ASP.NET MVC (3/4) http://host/webapp/Customer/Detail/1
  • 11. Introduzione a ASP.NET MVC (4/4) http://host/webapp/Customer/Detail/1
  • 12.
  • 16. EmptyResult. Restituitodalle action chevoglianorestituire “null”.
  • 17.
  • 18. Dati: Controller->View Per trasferire dati dal controller alla view: ViewData YourView.Model=Presentation View Model
  • 20. Dati: View->Controller Per trasferire dati dalla view al controller: Parametridella action (convention over configuration): ognielemento in query string èmappatosu un parametroomonimo ognielemento del <form /> èmappatosu un parametroomonimo FormCollection >>>Model binding<<<
  • 22. Data Entry Built in: Usare i metodi helper per definire i “campi” Taggareil ViewModel mediante DataAnnotations Ricordarsi Html.ValidationMessageFor<>() e/o Html.ValidationSummary() [Opzionale]Impostare .input-validation-error nel css [Opzionale]: EditorTemplates, DisplayTemplates
  • 24. Data Entry <3 JQuery Client side validation Inclusione degli script JS <% Html.EnableClientSideValidation(); %> JQuery plug-in, es: JQuery UI (tab, datepicker, …) JQGrid Assert.IsTrueLove(EditorTemplates, JQuery)
  • 26. AspNetMvc.More(); Esempi: [FX4 only]<%: … %> (equivalente a <% =Html.Encode(…) %>) IoC Custom ActionResult: Generare Thumbnail Generare Atom/RSS (http://www.ugidotnet.org/Article/Detail/280) “Componentization”: RenderPartial+RenderAction Test Aree
  • 28. MVC @ ManagedDesigns In azienda usiamo il toolkit MVC dalle prime CTP della v1, ed abbiamo raggiunto una struttura «standardizzata» dei progetti: Model 3 LayeredExpressionTrees
  • 29. MVC goes Model 3 Model 2 separa il Controller in: Front Controller Page Controller Model 3 separa il Model in: View Model: rappresenta i dati che la view si impegna a presentare all’utente Worker Service: è la façade che il page controller utilizza per produrre il View Model E’ il Single ResponsibilityPrinciple, baby!
  • 30. Nevermind the bollocks, here’s the Model 3
  • 31. LayeredExpressionTrees (LET idiom) Facciamo un gioco: invece di definire un «botto» di DTO, facciamo che layer e servizi si scambino degli IQueryable<YourFavouriteDomainEntity>, facendo «emergere» la query e specificando la proiezione solo all’ultimo momento? L’espressione «Capra e cavoli» vi dice niente? 
  • 32. C’mon Query LET’s go party (ah-ah-ah, yeah!)
  • 33. Slide e demo Slide sul mio blog: http://blogs.ugidotnet.org/pape Demo su CodePlex: http://nsk.codeplex.com