SlideShare ist ein Scribd-Unternehmen logo
1 von 29
Downloaden Sie, um offline zu lesen
© 2009 SPR Companies. All rights reserved.
MPS Partners
An SPR Company
Brown Bag Lunch Series: 10/06/2010
An Introduction To ASP.NET MVC
by Mayank Srivastava
http://www.MayankSrivastava.com
Table of Contents
The Framework
Frequently
Bought Together
The Pattern
The Product
So what is MVC pattern?
Image from Wikipedia.org
Model-View-Controller is an architectural pattern that isolates "domain
logic" (the application logic for the user) from the user interface (input
and presentation), permitting independent development, testing and
maintenance of each (separation of concerns).
Basics
ASP.NET Web Forms
+ MVC Pattern
= ASP.NET MVC
ASP.NET
+ MVC Pattern
= ASP.NET MVC
ASP.NET == ASP.NET Web Forms
ASP.NET - The Song Remains The Same
Web Forms
Request (*.aspx) PageHandlerFactory
Responsible for page processing engine
Create a server form
Execute Page life cycle
Load View state / Control state
Server Form / Page
Response
(Browser understandable content)
Inheriting
System.Web.UI.Page
does the trick.
So what is MVC pattern?
Model
• Domain-specific representation of data
• Business logic
• Storage layer is an implementation detail
So what is MVC pattern?
View
• Presents data to the user
• Read-only views as well as forms
• Minimal display-only logic
So what is MVC pattern?
Controller
• Responds to requests
• Connects models to view
• Invokes model code as appropriate
MVC based ASP.NET framework
Request (URL) Controller
Response
(Browser understandable
content)
Model
View
-> Get the model (if needed)
-> Bind the model to the view (if needed)
->Render the view
Viewsknowhowtopresentmodels
Other related frameworks - http://en.wikipedia.org/wiki/Model%E2%80%93View%E2%80%93Controller
So what changed…
No Page life cycle
• No Server page, no server controls, only Views!
• Web is state ‘LESS’ environment.
• An asynchronous call should be an asynchronous call.
No View state
• Again, web is state ‘LESS’ environment.
• In hindsight, for the stateless web - state should be Model’s
responsibility, not View’s overhead.
No Postback
• Only Http verbs – Get, Post, Put, Delete.
Over to Visual Studio
A Quick comparison
• http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx
• http://demos.telerik.com/aspnet-mvc/grid
Asynchronous when you need
Synchronous when you don’t
Web Forms
MVC
Try reload / paging on Telerik’s WebForm’s Grid and
compare the performance against Telerik’s MVC grid.
Page 14
Some more Super Hero talk
Page 15
Routing
It’s all about Routes, not file path.
 Application/Controller/Action/Parameter
 Or whatever you want
 Search Engine Optimization 
http://ProductsOnline.com/Products/Details/Batmobile
http://ProductsOnline.com/Products/Catalogs/List/SmartPhones
http://BlogSite.com/Blogs@1/30/2009
Imagine possibilities –
 Windows Workflow Foundation
 RSS feeds
 Window communication foundation
 The Browse / Ajaxify Pretty much anything!
Over to Visual Studio
Page 17
Deeper dive
Oh and by the way –
ASP.NET MVC, aka System.Web.Mvc, is Open Source
Check out the code on :- http://aspnet.codeplex.com/wikipage?title=MVC
Page 18
Frequently bought together
Customers Who Bought This Item Also Bought
• n-Tier application architecture (Separation of concern).
• IoC – Inversion of control (Dependency injection).
• TDD – Test Driven Development.
18
Page 19
Separation of Concern
What concern? Why are you concerned? My application works fine!
Remember Models?
Page 20
Separation of concern
Model Nothing but POCO
Domain-specific representation of
data
Domain Models
Business logic Business Layer
Storage layer is an implementation
detail
Data Access Layer
Page 21
Separation of concern
Most Common (rather default) Design Patterns
• Services Based for extendibility
• Repositories for Data Access Layer
Page 22
DI & IoC
Dependency injection
(Image - http://www.microbotic.org)
• Static kernel based container
• Control over scope (singleton, Request)
• Popular frameworks – Unity (Enterprise Library), StructureMap,
Ninject, Castle Windsor, Spring.NET…
Page 23
Inversion of Control
Database
Web Client
Services Repositories
ICacheService ICacheRepository
WP7 App
Facebook Canvas
Use HttpCacheService : ICacheService
& SQLCacheRepository : ICacheRepository
Use WPCacheService : ICacheService &
LocalFileCacheRepository : ICacheRepository
Use WPCacheService : ICacheService &
LocalFileCacheRepository : ICacheRepository
How should I handle your cache needs?
Page 24
Test Driven Development
Why is it the big breakthrough?
http://ASP.NET.WebForms.com/ProductList.aspx
Is it testable? – No… (at least not easily)
http://ASP.NET.MVC.com/Product/List
Is it testable? – Yes!
var product = new ProductController();
var result = product.List();
Page 25
Why MVC
• App Driven Development
• Industry moving towards Usability
• It’s all about user experience
Usability = (Functionality ^ Look) * Feel;
Page 26
Future?
Is this the end of Web Forms?
Now that MVC is here.
No! That’s ridicules!
(as on Channel9.MSDN.com)
Page 27
Future?
Flashback
Is this the end of VB?
Now that C# is here.
No! That’s ridicules!
However VB can’t be used on some cool stuff
like Window Phone, the .NET Micro Framework
err…I mean VB is equally good.
Page 28
Resources
Learning Resources:
http://www.asp.net/mvc
http://nerddinner.codeplex.com/
http://blog.wekeroad.com/2010/05/24/mvc-starter-2
Prominent bloggers:
Scott Guthrie - http://weblogs.asp.net/scottgu/
Scott Hanselman - http://www.hanselman.com/blog/
Phil Haak - http://haacked.com/
Rob Conery - http://blog.wekeroad.com/
Jon Galloway - http://weblogs.asp.net/jgalloway/
Stevens Anderson - http://blog.stevensanderson.com/
Brad Wilson - http://bradwilson.typepad.com/
Also:
Me :) - http://AspNetLive.BlogSpot.com/
Page 29
Questions

Weitere ähnliche Inhalte

Was ist angesagt?

WebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page AppsWebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page Apps
Pop Apps
 
HTML5 Offline Web Application
HTML5 Offline Web ApplicationHTML5 Offline Web Application
HTML5 Offline Web Application
Allan Huang
 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdev
damianofusco
 

Was ist angesagt? (20)

Web technologies practical guide
Web technologies practical guideWeb technologies practical guide
Web technologies practical guide
 
The Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devicesThe Mobile Web - HTML5 on mobile devices
The Mobile Web - HTML5 on mobile devices
 
Single page application and Framework
Single page application and FrameworkSingle page application and Framework
Single page application and Framework
 
HTML5 Offline Web Applications (Silicon Valley User Group)
HTML5 Offline Web Applications (Silicon Valley User Group)HTML5 Offline Web Applications (Silicon Valley User Group)
HTML5 Offline Web Applications (Silicon Valley User Group)
 
Offline Web Apps
Offline Web AppsOffline Web Apps
Offline Web Apps
 
Em presentation victor herman
Em presentation victor hermanEm presentation victor herman
Em presentation victor herman
 
Single Page Apps
Single Page AppsSingle Page Apps
Single Page Apps
 
WebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page AppsWebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page Apps
 
Single Page Applications
Single Page ApplicationsSingle Page Applications
Single Page Applications
 
Single page applications
Single page applicationsSingle page applications
Single page applications
 
single page application
single page applicationsingle page application
single page application
 
HTML5 Offline Web Application
HTML5 Offline Web ApplicationHTML5 Offline Web Application
HTML5 Offline Web Application
 
Introduction to headless browsers
Introduction to headless browsersIntroduction to headless browsers
Introduction to headless browsers
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applications
 
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
JavaCro'14 - Consuming Java EE Backends in Desktop, Web, and Mobile Frontends...
 
Ajax Using JSP with prototype.js
Ajax Using JSP with prototype.jsAjax Using JSP with prototype.js
Ajax Using JSP with prototype.js
 
Building High-Performance applications with .NET 5 and Vue JS 3
Building High-Performance applications with .NET 5 and Vue JS 3Building High-Performance applications with .NET 5 and Vue JS 3
Building High-Performance applications with .NET 5 and Vue JS 3
 
Single Page Application
Single Page ApplicationSingle Page Application
Single Page Application
 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdev
 
SGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page InterfaceSGCE 2012 Lightning Talk-Single Page Interface
SGCE 2012 Lightning Talk-Single Page Interface
 

Andere mochten auch (6)

Why do you need REST
Why do you need RESTWhy do you need REST
Why do you need REST
 
CNUG - Effective Data Visualization
CNUG - Effective Data VisualizationCNUG - Effective Data Visualization
CNUG - Effective Data Visualization
 
Introduction to HTML5
Introduction to HTML5Introduction to HTML5
Introduction to HTML5
 
CNUG ASP.NET MVC 4 – New Features
CNUG ASP.NET MVC 4 – New FeaturesCNUG ASP.NET MVC 4 – New Features
CNUG ASP.NET MVC 4 – New Features
 
CNUG TDD June 2014
CNUG TDD June 2014CNUG TDD June 2014
CNUG TDD June 2014
 
CNUG - Getting started on IoT Devices & Solutions using Windows 10 & Microsof...
CNUG - Getting started on IoT Devices & Solutions using Windows 10 & Microsof...CNUG - Getting started on IoT Devices & Solutions using Windows 10 & Microsof...
CNUG - Getting started on IoT Devices & Solutions using Windows 10 & Microsof...
 

Ähnlich wie Introduction to ASP.NET MVC

Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
MaslowB
 

Ähnlich wie Introduction to ASP.NET MVC (20)

ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET Presentation
 
Mvc presentation
Mvc presentationMvc presentation
Mvc presentation
 
Aspnet mvc
Aspnet mvcAspnet mvc
Aspnet mvc
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applications
 
MVC Framework
MVC FrameworkMVC Framework
MVC Framework
 
What is ASP.NET MVC
What is ASP.NET MVCWhat is ASP.NET MVC
What is ASP.NET MVC
 
Asp 1a-aspnetmvc
Asp 1a-aspnetmvcAsp 1a-aspnetmvc
Asp 1a-aspnetmvc
 
Aspnetmvc 1
Aspnetmvc 1Aspnetmvc 1
Aspnetmvc 1
 
Mvc Brief Overview
Mvc Brief OverviewMvc Brief Overview
Mvc Brief Overview
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring Framework
 
MSDN - ASP.NET MVC
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
 
MVC & backbone.js
MVC & backbone.jsMVC & backbone.js
MVC & backbone.js
 
ASP.NET MVC overview
ASP.NET MVC overviewASP.NET MVC overview
ASP.NET MVC overview
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8
 
Web development concepts using microsoft technologies
Web development concepts using microsoft technologiesWeb development concepts using microsoft technologies
Web development concepts using microsoft technologies
 
Spring tutorials
Spring tutorialsSpring tutorials
Spring tutorials
 
Asp.Net MVC3 - Basics
Asp.Net MVC3 - BasicsAsp.Net MVC3 - Basics
Asp.Net MVC3 - Basics
 
Sitecore MVC: What it is and why it's important
Sitecore MVC: What it is and why it's importantSitecore MVC: What it is and why it's important
Sitecore MVC: What it is and why it's important
 
Asp.netmvc handson
Asp.netmvc handsonAsp.netmvc handson
Asp.netmvc handson
 
MVC architecture by Mohd.Awais on 18th Aug, 2017
MVC architecture by Mohd.Awais on 18th Aug, 2017MVC architecture by Mohd.Awais on 18th Aug, 2017
MVC architecture by Mohd.Awais on 18th Aug, 2017
 

Kürzlich hochgeladen

Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
Joaquim Jorge
 

Kürzlich hochgeladen (20)

[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Automating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps ScriptAutomating Google Workspace (GWS) & more with Apps Script
Automating Google Workspace (GWS) & more with Apps Script
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 

Introduction to ASP.NET MVC

  • 1. © 2009 SPR Companies. All rights reserved. MPS Partners An SPR Company Brown Bag Lunch Series: 10/06/2010 An Introduction To ASP.NET MVC by Mayank Srivastava http://www.MayankSrivastava.com
  • 2. Table of Contents The Framework Frequently Bought Together The Pattern The Product
  • 3. So what is MVC pattern? Image from Wikipedia.org Model-View-Controller is an architectural pattern that isolates "domain logic" (the application logic for the user) from the user interface (input and presentation), permitting independent development, testing and maintenance of each (separation of concerns).
  • 4. Basics ASP.NET Web Forms + MVC Pattern = ASP.NET MVC ASP.NET + MVC Pattern = ASP.NET MVC ASP.NET == ASP.NET Web Forms
  • 5. ASP.NET - The Song Remains The Same
  • 6. Web Forms Request (*.aspx) PageHandlerFactory Responsible for page processing engine Create a server form Execute Page life cycle Load View state / Control state Server Form / Page Response (Browser understandable content) Inheriting System.Web.UI.Page does the trick.
  • 7. So what is MVC pattern? Model • Domain-specific representation of data • Business logic • Storage layer is an implementation detail
  • 8. So what is MVC pattern? View • Presents data to the user • Read-only views as well as forms • Minimal display-only logic
  • 9. So what is MVC pattern? Controller • Responds to requests • Connects models to view • Invokes model code as appropriate
  • 10. MVC based ASP.NET framework Request (URL) Controller Response (Browser understandable content) Model View -> Get the model (if needed) -> Bind the model to the view (if needed) ->Render the view Viewsknowhowtopresentmodels Other related frameworks - http://en.wikipedia.org/wiki/Model%E2%80%93View%E2%80%93Controller
  • 11. So what changed… No Page life cycle • No Server page, no server controls, only Views! • Web is state ‘LESS’ environment. • An asynchronous call should be an asynchronous call. No View state • Again, web is state ‘LESS’ environment. • In hindsight, for the stateless web - state should be Model’s responsibility, not View’s overhead. No Postback • Only Http verbs – Get, Post, Put, Delete.
  • 12. Over to Visual Studio
  • 13. A Quick comparison • http://demos.telerik.com/aspnet-ajax/grid/examples/overview/defaultcs.aspx • http://demos.telerik.com/aspnet-mvc/grid Asynchronous when you need Synchronous when you don’t Web Forms MVC Try reload / paging on Telerik’s WebForm’s Grid and compare the performance against Telerik’s MVC grid.
  • 14. Page 14 Some more Super Hero talk
  • 15. Page 15 Routing It’s all about Routes, not file path.  Application/Controller/Action/Parameter  Or whatever you want  Search Engine Optimization  http://ProductsOnline.com/Products/Details/Batmobile http://ProductsOnline.com/Products/Catalogs/List/SmartPhones http://BlogSite.com/Blogs@1/30/2009 Imagine possibilities –  Windows Workflow Foundation  RSS feeds  Window communication foundation  The Browse / Ajaxify Pretty much anything!
  • 16. Over to Visual Studio
  • 17. Page 17 Deeper dive Oh and by the way – ASP.NET MVC, aka System.Web.Mvc, is Open Source Check out the code on :- http://aspnet.codeplex.com/wikipage?title=MVC
  • 18. Page 18 Frequently bought together Customers Who Bought This Item Also Bought • n-Tier application architecture (Separation of concern). • IoC – Inversion of control (Dependency injection). • TDD – Test Driven Development. 18
  • 19. Page 19 Separation of Concern What concern? Why are you concerned? My application works fine! Remember Models?
  • 20. Page 20 Separation of concern Model Nothing but POCO Domain-specific representation of data Domain Models Business logic Business Layer Storage layer is an implementation detail Data Access Layer
  • 21. Page 21 Separation of concern Most Common (rather default) Design Patterns • Services Based for extendibility • Repositories for Data Access Layer
  • 22. Page 22 DI & IoC Dependency injection (Image - http://www.microbotic.org) • Static kernel based container • Control over scope (singleton, Request) • Popular frameworks – Unity (Enterprise Library), StructureMap, Ninject, Castle Windsor, Spring.NET…
  • 23. Page 23 Inversion of Control Database Web Client Services Repositories ICacheService ICacheRepository WP7 App Facebook Canvas Use HttpCacheService : ICacheService & SQLCacheRepository : ICacheRepository Use WPCacheService : ICacheService & LocalFileCacheRepository : ICacheRepository Use WPCacheService : ICacheService & LocalFileCacheRepository : ICacheRepository How should I handle your cache needs?
  • 24. Page 24 Test Driven Development Why is it the big breakthrough? http://ASP.NET.WebForms.com/ProductList.aspx Is it testable? – No… (at least not easily) http://ASP.NET.MVC.com/Product/List Is it testable? – Yes! var product = new ProductController(); var result = product.List();
  • 25. Page 25 Why MVC • App Driven Development • Industry moving towards Usability • It’s all about user experience Usability = (Functionality ^ Look) * Feel;
  • 26. Page 26 Future? Is this the end of Web Forms? Now that MVC is here. No! That’s ridicules! (as on Channel9.MSDN.com)
  • 27. Page 27 Future? Flashback Is this the end of VB? Now that C# is here. No! That’s ridicules! However VB can’t be used on some cool stuff like Window Phone, the .NET Micro Framework err…I mean VB is equally good.
  • 28. Page 28 Resources Learning Resources: http://www.asp.net/mvc http://nerddinner.codeplex.com/ http://blog.wekeroad.com/2010/05/24/mvc-starter-2 Prominent bloggers: Scott Guthrie - http://weblogs.asp.net/scottgu/ Scott Hanselman - http://www.hanselman.com/blog/ Phil Haak - http://haacked.com/ Rob Conery - http://blog.wekeroad.com/ Jon Galloway - http://weblogs.asp.net/jgalloway/ Stevens Anderson - http://blog.stevensanderson.com/ Brad Wilson - http://bradwilson.typepad.com/ Also: Me :) - http://AspNetLive.BlogSpot.com/