SlideShare a Scribd company logo
1 of 45
Download to read offline
Sviluppo applicazioni web e linguaggio HTML

                             LEZIONE 04




ASP.NET
Getting Started …
ASP.NET
Nel 2002/2003
      Microsoft porta sul web
                    l’esperienza
dell’event-driven programming

                    Nascono le
               WebForms
ma è un castello di carte
   costruito per rendere
         l’http “stateful”
         e mascherare il
  web da applicazione
                 desktop




         Embrace HTTP and HTML—don't hide it
                             (Chris Tavares)
Spinto dalla community,
nel 2009 arriva
un aiuto dal passato …




      … tutto ebbe inizio nel lontano 1970 con Smalltalk.
Model
Contiene o
 rappresenta i
 dati applicativi




Model
Renderizza
parte del
modello
sulla UI


             Model
Processa le richieste
degli utenti compilando
il modello e scegliendo
la view da renderizzare




   Model
Event driven
programming     vs   MVC
and the   winner is …
and the   winner is …

   MVC
Separation
of
concerns (SoC)

         … ogni cosa al suo posto.
No ViewState
No Postback
No Page life-cycle



    … lasciamo che get e post facciano il loro lavoro.
Maggior
controllo sul
codice generato


                … il web è HTML!
Testability




              … avanti con lo unit testing!
E’ Open Source!




      … posso modificare e compilare il sorgente!
More than this …




             … andiamo a vedere
La mia prima
applicazione MVC
Partiamo da una soluzione vuota
Aggiungiamo un progetto ASP.NET MVC 3
Struttura di una applicazione MVC
Model s



Struttura di una applicazione MVC
s



Struttura di una applicazione MVC
Controller s




Struttura di una applicazione MVC
Rispondere
a una richiesta
Convention
over
configuration


       … se possiamo evitiamo il codice di plumbing.
/Home/About




        convention over configuration
/Home/About




        convention over configuration
/Home/About




        convention over configuration
Partiamo
dal model
Domain Model
Accesso
ai dati
Struttura del database relazionale
…


    Popoliamo il database con dati di test
La rappresentazione dei dati
nelle tabelle di un database è
diversa da quella negli oggetti
di un dominio




                      impedance mismatch
Allora utilizziamo un   ORM
( Object - Relation Mapper )

                   Definisce una mappatura tra
                   database e dominio in modo
                    da rendere “trasparente” la
                        persistenza degli oggetti




                  ad esempio Entity Framework
Building an MVC 3 App
with Code First and
Entity Framework 4.1
by Julie Lerman
• Installare l’Entity Framework da NuGet
• Creare una classe che erediti dal tipo
  DbContext
• Impostare una proprietà DbSet<T> per
  ogni classe T della quale vogliamo la
  persistenza
• Aggiungere nel web.config la stringa
  di connessione al database



    Come configurare l’Entity Framework
Convention
over
configuration


       … se possiamo evitiamo il codice di plumbing.
• E questo è il codice per accedere ai
  dati salvati nel database:




         Accedere ai dati del DbContext
continua …
Credits
Le immagini contenute in questa presentazione
hanno licenza Creative Commons


Slide 3: http://www.flickr.com/photos/gato-gato-gato/4166319893/in/photostream/
Slide 4: http://www.flickr.com/photos/gibbons/2294375187/in/photostream/
Slide 10: http://www.flickr.com/photos/49379577@N00/2420070827/in/photostream/
Slide 35: http://www.flickr.com/photos/ididj0emama/2276657116/in/photostream/
Thank You   MANUEL SCAPOLAN
            website: www.manuelscapolan.it
            twitter: manuelscapolan
            e-mail: info@manuelscapolan.it

More Related Content

Similar to ASP.NET

Fe02 ria con breeze e knockout
Fe02   ria con breeze e knockoutFe02   ria con breeze e knockout
Fe02 ria con breeze e knockoutDotNetCampus
 
Hands on MVC - Mastering the Web
Hands on MVC - Mastering the WebHands on MVC - Mastering the Web
Hands on MVC - Mastering the WebClaudio Gandelli
 
Alessandro Forte - MVP vs MVC
Alessandro Forte - MVP vs MVCAlessandro Forte - MVP vs MVC
Alessandro Forte - MVP vs MVCAlessandro Forte
 
Spring Framework
Spring FrameworkSpring Framework
Spring FrameworkNaLUG
 
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
 
MVVM senza fronzoli con Caliburn.Micro
MVVM senza fronzoli con Caliburn.MicroMVVM senza fronzoli con Caliburn.Micro
MVVM senza fronzoli con Caliburn.MicroMarco Amendola
 
Progetto SOD Davide Sito
Progetto SOD Davide SitoProgetto SOD Davide Sito
Progetto SOD Davide SitoDavide Sito
 
WPF & LINQ: VB T&T Community After Hour @ Microsoft Days 08
WPF & LINQ: VB T&T Community After Hour @ Microsoft Days 08WPF & LINQ: VB T&T Community After Hour @ Microsoft Days 08
WPF & LINQ: VB T&T Community After Hour @ Microsoft Days 08Alessandro Del Sole
 
Blazor: are we ready for the launch?
Blazor: are we ready for the launch?Blazor: are we ready for the launch?
Blazor: are we ready for the launch?Andrea Agnoletto
 
Win05 accesso ai dati in win 8
Win05   accesso ai dati in win 8Win05   accesso ai dati in win 8
Win05 accesso ai dati in win 8DotNetCampus
 
Applicazioni web based
Applicazioni web basedApplicazioni web based
Applicazioni web basedMarco Liverani
 
Sviluppo Web Agile con Castle Monorail
Sviluppo Web Agile con Castle MonorailSviluppo Web Agile con Castle Monorail
Sviluppo Web Agile con Castle MonorailDotNetMarche
 
Sistemi Context-aware: Esercitazione 3
Sistemi Context-aware: Esercitazione 3Sistemi Context-aware: Esercitazione 3
Sistemi Context-aware: Esercitazione 3Marco Loregian
 

Similar to ASP.NET (20)

Fe02 ria con breeze e knockout
Fe02   ria con breeze e knockoutFe02   ria con breeze e knockout
Fe02 ria con breeze e knockout
 
Hands on MVC - Mastering the Web
Hands on MVC - Mastering the WebHands on MVC - Mastering the Web
Hands on MVC - Mastering the Web
 
Alessandro Forte - MVP vs MVC
Alessandro Forte - MVP vs MVCAlessandro Forte - MVP vs MVC
Alessandro Forte - MVP vs MVC
 
Spring Framework
Spring FrameworkSpring Framework
Spring Framework
 
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
 
MVVM senza fronzoli con Caliburn.Micro
MVVM senza fronzoli con Caliburn.MicroMVVM senza fronzoli con Caliburn.Micro
MVVM senza fronzoli con Caliburn.Micro
 
Knockout.js
Knockout.jsKnockout.js
Knockout.js
 
Wcf data services
Wcf data servicesWcf data services
Wcf data services
 
MVC and Struts 1
MVC and Struts 1MVC and Struts 1
MVC and Struts 1
 
Many Designs Elements
Many Designs ElementsMany Designs Elements
Many Designs Elements
 
Progetto SOD Davide Sito
Progetto SOD Davide SitoProgetto SOD Davide Sito
Progetto SOD Davide Sito
 
WPF & LINQ: VB T&T Community After Hour @ Microsoft Days 08
WPF & LINQ: VB T&T Community After Hour @ Microsoft Days 08WPF & LINQ: VB T&T Community After Hour @ Microsoft Days 08
WPF & LINQ: VB T&T Community After Hour @ Microsoft Days 08
 
Blazor: are we ready for the launch?
Blazor: are we ready for the launch?Blazor: are we ready for the launch?
Blazor: are we ready for the launch?
 
Novità di Asp.Net 4.0
Novità di Asp.Net 4.0Novità di Asp.Net 4.0
Novità di Asp.Net 4.0
 
ASP.NET MVC Intro
ASP.NET MVC IntroASP.NET MVC Intro
ASP.NET MVC Intro
 
Win05 accesso ai dati in win 8
Win05   accesso ai dati in win 8Win05   accesso ai dati in win 8
Win05 accesso ai dati in win 8
 
Applicazioni web based
Applicazioni web basedApplicazioni web based
Applicazioni web based
 
Sviluppo Web Agile con Castle Monorail
Sviluppo Web Agile con Castle MonorailSviluppo Web Agile con Castle Monorail
Sviluppo Web Agile con Castle Monorail
 
Sistemi Context-aware: Esercitazione 3
Sistemi Context-aware: Esercitazione 3Sistemi Context-aware: Esercitazione 3
Sistemi Context-aware: Esercitazione 3
 
Il web 2.0
Il web 2.0Il web 2.0
Il web 2.0
 

More from Manuel Scapolan

TFS and Scrum - Lessons Learned
TFS and Scrum - Lessons LearnedTFS and Scrum - Lessons Learned
TFS and Scrum - Lessons LearnedManuel Scapolan
 
Scrum? E' come fare il bucato!
Scrum? E' come fare il bucato!Scrum? E' come fare il bucato!
Scrum? E' come fare il bucato!Manuel Scapolan
 
Domain Driven Design e CQRS
Domain Driven Design e CQRSDomain Driven Design e CQRS
Domain Driven Design e CQRSManuel Scapolan
 
ASP.NET MVC3 - Tutti i compiti del Controller
ASP.NET MVC3 - Tutti i compiti del ControllerASP.NET MVC3 - Tutti i compiti del Controller
ASP.NET MVC3 - Tutti i compiti del ControllerManuel Scapolan
 
ASP.NET MVC 3 - Presentare i dati nella View
ASP.NET MVC 3 - Presentare i dati nella ViewASP.NET MVC 3 - Presentare i dati nella View
ASP.NET MVC 3 - Presentare i dati nella ViewManuel Scapolan
 
JavaScript Object Oriented
JavaScript Object OrientedJavaScript Object Oriented
JavaScript Object OrientedManuel Scapolan
 
Tutte le novità di ASP.NET MVC3
Tutte le novità di ASP.NET MVC3Tutte le novità di ASP.NET MVC3
Tutte le novità di ASP.NET MVC3Manuel Scapolan
 
Managed Extensibility Framework (MEF)
Managed Extensibility Framework (MEF)Managed Extensibility Framework (MEF)
Managed Extensibility Framework (MEF)Manuel Scapolan
 
Dai delegati a LINQ con C#
Dai delegati a LINQ con C#Dai delegati a LINQ con C#
Dai delegati a LINQ con C#Manuel Scapolan
 
C# e la Framework Class Library
C# e la Framework Class LibraryC# e la Framework Class Library
C# e la Framework Class LibraryManuel Scapolan
 
AntiPatterns: i vizi del programmatore
AntiPatterns: i vizi del programmatoreAntiPatterns: i vizi del programmatore
AntiPatterns: i vizi del programmatoreManuel Scapolan
 
Entity Framework 4.0 vs NHibernate
Entity Framework 4.0 vs NHibernateEntity Framework 4.0 vs NHibernate
Entity Framework 4.0 vs NHibernateManuel Scapolan
 

More from Manuel Scapolan (16)

TFS and Scrum - Lessons Learned
TFS and Scrum - Lessons LearnedTFS and Scrum - Lessons Learned
TFS and Scrum - Lessons Learned
 
Scrum? E' come fare il bucato!
Scrum? E' come fare il bucato!Scrum? E' come fare il bucato!
Scrum? E' come fare il bucato!
 
Domain Driven Design e CQRS
Domain Driven Design e CQRSDomain Driven Design e CQRS
Domain Driven Design e CQRS
 
NOSQL
NOSQLNOSQL
NOSQL
 
ASP.NET MVC3 - Tutti i compiti del Controller
ASP.NET MVC3 - Tutti i compiti del ControllerASP.NET MVC3 - Tutti i compiti del Controller
ASP.NET MVC3 - Tutti i compiti del Controller
 
ASP.NET MVC 3 - Presentare i dati nella View
ASP.NET MVC 3 - Presentare i dati nella ViewASP.NET MVC 3 - Presentare i dati nella View
ASP.NET MVC 3 - Presentare i dati nella View
 
JavaScript Object Oriented
JavaScript Object OrientedJavaScript Object Oriented
JavaScript Object Oriented
 
JavaScript
JavaScriptJavaScript
JavaScript
 
HTML e CSS
HTML e CSSHTML e CSS
HTML e CSS
 
Tutte le novità di ASP.NET MVC3
Tutte le novità di ASP.NET MVC3Tutte le novità di ASP.NET MVC3
Tutte le novità di ASP.NET MVC3
 
Managed Extensibility Framework (MEF)
Managed Extensibility Framework (MEF)Managed Extensibility Framework (MEF)
Managed Extensibility Framework (MEF)
 
Dai delegati a LINQ con C#
Dai delegati a LINQ con C#Dai delegati a LINQ con C#
Dai delegati a LINQ con C#
 
C# e la Framework Class Library
C# e la Framework Class LibraryC# e la Framework Class Library
C# e la Framework Class Library
 
AntiPatterns: i vizi del programmatore
AntiPatterns: i vizi del programmatoreAntiPatterns: i vizi del programmatore
AntiPatterns: i vizi del programmatore
 
OOP with C#
OOP with C#OOP with C#
OOP with C#
 
Entity Framework 4.0 vs NHibernate
Entity Framework 4.0 vs NHibernateEntity Framework 4.0 vs NHibernate
Entity Framework 4.0 vs NHibernate
 

ASP.NET