SlideShare une entreprise Scribd logo
1  sur  29
Télécharger pour lire hors ligne
© 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

Contenu connexe

Tendances

Web technologies practical guide
Web technologies practical guideWeb technologies practical guide
Web technologies practical guidesamir azazy
 
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 devicesWesley Hales
 
Single page application and Framework
Single page application and FrameworkSingle page application and Framework
Single page application and FrameworkChandrasekar G
 
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)robinzimmermann
 
Em presentation victor herman
Em presentation victor hermanEm presentation victor herman
Em presentation victor hermanVictor Herman
 
Single Page Apps
Single Page AppsSingle Page Apps
Single Page AppsGil Fink
 
WebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page AppsWebNetConf 2012 - Single Page Apps
WebNetConf 2012 - Single Page AppsPop Apps
 
Single page applications
Single page applicationsSingle page applications
Single page applicationsDiego Cardozo
 
single page application
single page applicationsingle page application
single page applicationRavindra K
 
HTML5 Offline Web Application
HTML5 Offline Web ApplicationHTML5 Offline Web Application
HTML5 Offline Web ApplicationAllan Huang
 
Building single page applications
Building single page applicationsBuilding single page applications
Building single page applicationsSC5.io
 
Ajax Using JSP with prototype.js
Ajax Using JSP with prototype.jsAjax Using JSP with prototype.js
Ajax Using JSP with prototype.jsTushar Chauhan
 
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 3Alexandre Malavasi
 
Lightweight webdev
Lightweight webdevLightweight webdev
Lightweight webdevdamianofusco
 
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 InterfaceDomingo Suarez Torres
 

Tendances (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
 

En vedette

CNUG - Effective Data Visualization
CNUG - Effective Data VisualizationCNUG - Effective Data Visualization
CNUG - Effective Data VisualizationMayank Srivastava
 
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 FeaturesMayank Srivastava
 
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...Mayank Srivastava
 

En vedette (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...
 

Similaire à Introduction to ASP.NET MVC

ASP.NET Presentation
ASP.NET PresentationASP.NET Presentation
ASP.NET PresentationRasel Khan
 
Mvc presentation
Mvc presentationMvc presentation
Mvc presentationMaslowB
 
Developing Java Web Applications
Developing Java Web ApplicationsDeveloping Java Web Applications
Developing Java Web Applicationshchen1
 
What is ASP.NET MVC
What is ASP.NET MVCWhat is ASP.NET MVC
What is ASP.NET MVCBrad Oyler
 
Getting Started with Spring Framework
Getting Started with Spring FrameworkGetting Started with Spring Framework
Getting Started with Spring FrameworkEdureka!
 
Using MVC with Kentico 8
Using MVC with Kentico 8Using MVC with Kentico 8
Using MVC with Kentico 8Thomas Robbins
 
Web development concepts using microsoft technologies
Web development concepts using microsoft technologiesWeb development concepts using microsoft technologies
Web development concepts using microsoft technologiesHosam Kamel
 
Spring tutorials
Spring tutorialsSpring tutorials
Spring tutorialsTIB Academy
 
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 importantnonlinear creations
 
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, 2017Innovation Studio
 

Similaire à 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
 

Dernier

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...apidays
 
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 TerraformAndrey Devyatkin
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century educationjfdjdjcjdnsjd
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
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 2024The Digital Insurer
 
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 WorkerThousandEyes
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
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, Adobeapidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
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...DianaGray10
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 

Dernier (20)

Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 
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
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
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
 
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
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
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
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
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...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 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/