SlideShare a Scribd company logo
ASP.NET MVCVolkanUzun
Web Developer at California State University, San BernardinoMS. Computer Science, MCP, and MCTSInterest Areas: TDD, Web Programming, Secure CodingUser group maniac, visiting many user groups in a monthBlog: http://www.msnetprogrammer.net/blog,Email: volkan@iedotnetug.orgTwitter: http://www.twitter.com/volkanuzunAbout Me
ASP.NET MVC Presentation
Classic ASP (Another Slow Page!?).NET Framework (Hurraay!!)ASP.NET v1.0 (No more slow pages)ASP.NET v1.1ASP.NET v2.0ASP.NET Ajax ASP.NET 3.5Silverlight ?!?!ASP.NET MVCASP.NET WebForms 4.0….MS Web Developer History
Easy to learn but?Maintenance?Test?Debugging?Complexity?What was wrong with ASP?
Desktop like programming paradigmLot’s of out ofbox controlsNo more spaghetti code?ASP.NET Web Forms
ViewState (supposed to    help you but?)DRYCan’t control HTML(Power is nothing without control)Best Practices? Separation of Concerns? (I don’t have any concern)What is wrong with ASP.NET WebForms?
New Patterns
MVCDifferent people reading about MVC in different places take different ideas from it and describe these as “MVC”.Martin Fowler, GUI Architectures Essay (July  2006)
Model–View–Controller (MVC) is an architectural pattern Formulated in 1979 by TrygveMikkjel Heyerdahl ReenskaugThe model is the domain-specific representation of the data upon which the application operatesThe controller receives input and initiates a response by making calls on model objects.The view renders the model into a form suitable for interactionWikipedia: MVC
A new web project type built on top of ASP.NET.
NOT replacing ASP.NET Web Forms.
Giving you more control over html.
An easier to test framework.
Another option to web development.
Open source.
Convention over configuration.ASP.NET MVC
No View State, No PostbackVery flexible, pluggable.Very clean URLs, rest friendly urls.Supports ASP.NET Providers: Membership Provider, Role Provider, Session, Cache etc…Open Source.Community Support.Supports Separation of Concerns.Plays well with othersWhy is it good?
Complete control over html!!No View State, No Postback!!Paradigm change.Few components .No formal validation support.Any Disadvantage?
WebForms are dead?MVC does not have as much support as WebForms?MVC guarantees better coding?A project is either MVC or WebForms?MVC is faster than WebForms?True / False
Browser requests /Products/ListRoute is selectedController is activated (Products)Controller executes the action method (List)Action talks to Model, prepares the ViewDataAction renders ViewBut what is it?
Located in Controllers folder, You can change itderived from Controller base classThe class name should be controller name + “Controller”Action Methods does the workDelete AccountControllerMove Controller’s to a separate projectController
The ambiguous part of ASP.NET MVCM is the only part of MVC that is not implemented in ASP.NET MVCView Model: How your data looks on the page, flat dataDomain Model: How your business data is, hierarchical dataAny ORM is fineMODEL
Just renders the page, no biz logic!!!No ViewState, no server controlsNO Codebehind, pls DON’TDefault ViewEngine is WebFormsCommunicates with Controller with ViewData DictionaryStrongly Typed ViewVIEW
FILE => NEW…Project Structure
Separate Domain Model and View ModelUse an ORMUse Repository PatternDomain Model should only validate domain rulesPresentation layer should NOT  care about persistence layerBest Practices on Model
FALSEViewModel == DomainModelThe most annoying part of Presentation Model is the synchronization between Presentation Model and view…Martin Fowler, GUI Architectures Essay, July 2004
Music Store AppDisplay AlbumsDisplay CustomersRefactor the ModelUse AutoMapperDEMO
No Business LogicNo Concrete DependenciesSmall Action MethodsDon’t mix HttpVerbsAvoid magic stringsUse controller as a traffic flow managerUnit test your expectationsAll the public methods are web accessibleUse OutputCacheBest Practices on Controller
Define Views in an enum:return View(viewNames.Index);Even Better use T4MVCView.ModelMVCContrib for RedirectToAction:return RedirectToAction<HomeController>(c=>c.Index)Removing Magics in Controller
Refactor View Names and Links with T4MVCCache the outputWrite simple unit testDEMO
Dependency Injectionprivate IBookRepositorybookRepository;public HomeController(){bookRepository = new BookRepository();} What if BookRepository has dependencies?
 Is it HomeContoller’s job to satisfy dependencies?
 Why does Home Controller have to know about BookRepository()?
Ad

More Related Content

What's hot (20)

MSDN - ASP.NET MVC
MSDN - ASP.NET MVCMSDN - ASP.NET MVC
MSDN - ASP.NET MVC
Maarten Balliauw
 
Introduction to mvc architecture
Introduction to mvc architectureIntroduction to mvc architecture
Introduction to mvc architecture
ravindraquicsolv
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
Vikas Jagtap
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
Hùng Nguyễn Huy
 
Introduction to ASP.NET
Introduction to ASP.NETIntroduction to ASP.NET
Introduction to ASP.NET
Rajkumarsoy
 
Jquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript BasicsJquery Complete Presentation along with Javascript Basics
Jquery Complete Presentation along with Javascript Basics
EPAM Systems
 
Lab #2: Introduction to Javascript
Lab #2: Introduction to JavascriptLab #2: Introduction to Javascript
Lab #2: Introduction to Javascript
Walid Ashraf
 
Spring Core
Spring CoreSpring Core
Spring Core
Pushan Bhattacharya
 
Servlets
ServletsServlets
Servlets
ZainabNoorGul
 
React js
React jsReact js
React js
Rajesh Kolla
 
Ajax presentation
Ajax presentationAjax presentation
Ajax presentation
Bharat_Kumawat
 
ASP.NET Lecture 1
ASP.NET Lecture 1ASP.NET Lecture 1
ASP.NET Lecture 1
Julie Iskander
 
jQuery for beginners
jQuery for beginnersjQuery for beginners
jQuery for beginners
Arulmurugan Rajaraman
 
Angular - Chapter 4 - Data and Event Handling
 Angular - Chapter 4 - Data and Event Handling Angular - Chapter 4 - Data and Event Handling
Angular - Chapter 4 - Data and Event Handling
WebStackAcademy
 
Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
Guddu gupta
 
Learn react-js
Learn react-jsLearn react-js
Learn react-js
C...L, NESPRESSO, WAFAASSURANCE, SOFRECOM ORANGE
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
Vikas Jagtap
 
AngularJS
AngularJSAngularJS
AngularJS
Maurice De Beijer [MVP]
 
Model view controller (mvc)
Model view controller (mvc)Model view controller (mvc)
Model view controller (mvc)
M Ahsan Khan
 
jQuery
jQueryjQuery
jQuery
Jay Poojara
 

Viewers also liked (6)

.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
Siraj Memon
 
C# basics
 C# basics C# basics
C# basics
Dinesh kumar
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
Jm Ramos
 
C#.NET
C#.NETC#.NET
C#.NET
gurchet
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
OpenSource Technologies Pvt. Ltd.
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
Arun Prasad
 
Ad

Similar to ASP.NET MVC Presentation (20)

Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
Volkan Uzun
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
Barry Gervin
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
Stefano Paluello
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
joselinoneto
 
Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0
Shiju Varghese
 
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5  Building Your First Web Application (A Beginner S GuideASP.NET MVC 5  Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
Alicia Buske
 
Php and-mvc
Php and-mvcPhp and-mvc
Php and-mvc
Manoj Sahoo
 
Asp.netmvc handson
Asp.netmvc handsonAsp.netmvc handson
Asp.netmvc handson
Prashant Kumar
 
Difference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcDifference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvc
Umar Ali
 
TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0
Shiju Varghese
 
MVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros DeveloperMVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros Developer
Nyros Technologies
 
No brainer
No brainerNo brainer
No brainer
Tanzim Saqib
 
Deep Dive: MVC Controller Architecture
Deep Dive: MVC Controller ArchitectureDeep Dive: MVC Controller Architecture
Deep Dive: MVC Controller Architecture
Chris Eargle
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
Dipika Wadhvani
 
Which is better asp.net mvc vs asp.net
Which is better  asp.net mvc vs asp.netWhich is better  asp.net mvc vs asp.net
Which is better asp.net mvc vs asp.net
Concetto Labs
 
MVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetMVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - Indiandotnet
Indiandotnet
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
Naga Harish M
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina
 
Beyond The MVC
Beyond The MVCBeyond The MVC
Beyond The MVC
george.james
 
Getting Started with ASP.NET MVC
Getting Started with ASP.NET MVCGetting Started with ASP.NET MVC
Getting Started with ASP.NET MVC
shobokshi
 
Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
Volkan Uzun
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
Barry Gervin
 
Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0Introduction to ASP.NET MVC 1.0
Introduction to ASP.NET MVC 1.0
Shiju Varghese
 
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5  Building Your First Web Application (A Beginner S GuideASP.NET MVC 5  Building Your First Web Application (A Beginner S Guide
ASP.NET MVC 5 Building Your First Web Application (A Beginner S Guide
Alicia Buske
 
Difference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvcDifference between asp.net web forms and asp.net mvc
Difference between asp.net web forms and asp.net mvc
Umar Ali
 
TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0TDD with ASP.NET MVC 1.0
TDD with ASP.NET MVC 1.0
Shiju Varghese
 
MVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros DeveloperMVC Architecture in ASP.Net By Nyros Developer
MVC Architecture in ASP.Net By Nyros Developer
Nyros Technologies
 
Deep Dive: MVC Controller Architecture
Deep Dive: MVC Controller ArchitectureDeep Dive: MVC Controller Architecture
Deep Dive: MVC Controller Architecture
Chris Eargle
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
Dipika Wadhvani
 
Which is better asp.net mvc vs asp.net
Which is better  asp.net mvc vs asp.netWhich is better  asp.net mvc vs asp.net
Which is better asp.net mvc vs asp.net
Concetto Labs
 
MVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - IndiandotnetMVC From Beginner to Advance in Indian Style by - Indiandotnet
MVC From Beginner to Advance in Indian Style by - Indiandotnet
Indiandotnet
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
eldorina
 
Getting Started with ASP.NET MVC
Getting Started with ASP.NET MVCGetting Started with ASP.NET MVC
Getting Started with ASP.NET MVC
shobokshi
 
Ad

Recently uploaded (20)

Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 
Automation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From AnywhereAutomation Dreamin': Capture User Feedback From Anywhere
Automation Dreamin': Capture User Feedback From Anywhere
Lynda Kane
 
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager APIUiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPath Community Berlin: Orchestrator API, Swagger, and Test Manager API
UiPathCommunity
 
2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx2025-05-Q4-2024-Investor-Presentation.pptx
2025-05-Q4-2024-Investor-Presentation.pptx
Samuele Fogagnolo
 
Buckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug LogsBuckeye Dreamin' 2023: De-fogging Debug Logs
Buckeye Dreamin' 2023: De-fogging Debug Logs
Lynda Kane
 
Image processinglab image processing image processing
Image processinglab image processing  image processingImage processinglab image processing  image processing
Image processinglab image processing image processing
RaghadHany
 
Linux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdfLinux Professional Institute LPIC-1 Exam.pdf
Linux Professional Institute LPIC-1 Exam.pdf
RHCSA Guru
 
Semantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AISemantic Cultivators : The Critical Future Role to Enable AI
Semantic Cultivators : The Critical Future Role to Enable AI
artmondano
 
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
#AdminHour presents: Hour of Code2018 slide deck from 12/6/2018
Lynda Kane
 
Datastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptxDatastucture-Unit 4-Linked List Presentation.pptx
Datastucture-Unit 4-Linked List Presentation.pptx
kaleeswaric3
 
Big Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur MorganBig Data Analytics Quick Research Guide by Arthur Morgan
Big Data Analytics Quick Research Guide by Arthur Morgan
Arthur Morgan
 
"PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System""PHP and MySQL CRUD Operations for Student Management System"
"PHP and MySQL CRUD Operations for Student Management System"
Jainul Musani
 
"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko"Rebranding for Growth", Anna Velykoivanenko
"Rebranding for Growth", Anna Velykoivanenko
Fwdays
 
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath MaestroDev Dives: Automate and orchestrate your processes with UiPath Maestro
Dev Dives: Automate and orchestrate your processes with UiPath Maestro
UiPathCommunity
 
Rusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond SparkRusty Waters: Elevating Lakehouses Beyond Spark
Rusty Waters: Elevating Lakehouses Beyond Spark
carlyakerly1
 
Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025Splunk Security Update | Public Sector Summit Germany 2025
Splunk Security Update | Public Sector Summit Germany 2025
Splunk
 
AI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global TrendsAI and Data Privacy in 2025: Global Trends
AI and Data Privacy in 2025: Global Trends
InData Labs
 
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdfThe Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
The Evolution of Meme Coins A New Era for Digital Currency ppt.pdf
Abi john
 
Drupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy ConsumptionDrupalcamp Finland – Measuring Front-end Energy Consumption
Drupalcamp Finland – Measuring Front-end Energy Consumption
Exove
 
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5..."Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
"Client Partnership — the Path to Exponential Growth for Companies Sized 50-5...
Fwdays
 
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdfSAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
SAP Modernization: Maximizing the Value of Your SAP S/4HANA Migration.pdf
Precisely
 

ASP.NET MVC Presentation

  • 2. Web Developer at California State University, San BernardinoMS. Computer Science, MCP, and MCTSInterest Areas: TDD, Web Programming, Secure CodingUser group maniac, visiting many user groups in a monthBlog: http://www.msnetprogrammer.net/blog,Email: [email protected]: http://www.twitter.com/volkanuzunAbout Me
  • 4. Classic ASP (Another Slow Page!?).NET Framework (Hurraay!!)ASP.NET v1.0 (No more slow pages)ASP.NET v1.1ASP.NET v2.0ASP.NET Ajax ASP.NET 3.5Silverlight ?!?!ASP.NET MVCASP.NET WebForms 4.0….MS Web Developer History
  • 5. Easy to learn but?Maintenance?Test?Debugging?Complexity?What was wrong with ASP?
  • 6. Desktop like programming paradigmLot’s of out ofbox controlsNo more spaghetti code?ASP.NET Web Forms
  • 7. ViewState (supposed to help you but?)DRYCan’t control HTML(Power is nothing without control)Best Practices? Separation of Concerns? (I don’t have any concern)What is wrong with ASP.NET WebForms?
  • 9. MVCDifferent people reading about MVC in different places take different ideas from it and describe these as “MVC”.Martin Fowler, GUI Architectures Essay (July 2006)
  • 10. Model–View–Controller (MVC) is an architectural pattern Formulated in 1979 by TrygveMikkjel Heyerdahl ReenskaugThe model is the domain-specific representation of the data upon which the application operatesThe controller receives input and initiates a response by making calls on model objects.The view renders the model into a form suitable for interactionWikipedia: MVC
  • 11. A new web project type built on top of ASP.NET.
  • 13. Giving you more control over html.
  • 14. An easier to test framework.
  • 15. Another option to web development.
  • 18. No View State, No PostbackVery flexible, pluggable.Very clean URLs, rest friendly urls.Supports ASP.NET Providers: Membership Provider, Role Provider, Session, Cache etc…Open Source.Community Support.Supports Separation of Concerns.Plays well with othersWhy is it good?
  • 19. Complete control over html!!No View State, No Postback!!Paradigm change.Few components .No formal validation support.Any Disadvantage?
  • 20. WebForms are dead?MVC does not have as much support as WebForms?MVC guarantees better coding?A project is either MVC or WebForms?MVC is faster than WebForms?True / False
  • 21. Browser requests /Products/ListRoute is selectedController is activated (Products)Controller executes the action method (List)Action talks to Model, prepares the ViewDataAction renders ViewBut what is it?
  • 22. Located in Controllers folder, You can change itderived from Controller base classThe class name should be controller name + “Controller”Action Methods does the workDelete AccountControllerMove Controller’s to a separate projectController
  • 23. The ambiguous part of ASP.NET MVCM is the only part of MVC that is not implemented in ASP.NET MVCView Model: How your data looks on the page, flat dataDomain Model: How your business data is, hierarchical dataAny ORM is fineMODEL
  • 24. Just renders the page, no biz logic!!!No ViewState, no server controlsNO Codebehind, pls DON’TDefault ViewEngine is WebFormsCommunicates with Controller with ViewData DictionaryStrongly Typed ViewVIEW
  • 26. Separate Domain Model and View ModelUse an ORMUse Repository PatternDomain Model should only validate domain rulesPresentation layer should NOT care about persistence layerBest Practices on Model
  • 27. FALSEViewModel == DomainModelThe most annoying part of Presentation Model is the synchronization between Presentation Model and view…Martin Fowler, GUI Architectures Essay, July 2004
  • 28. Music Store AppDisplay AlbumsDisplay CustomersRefactor the ModelUse AutoMapperDEMO
  • 29. No Business LogicNo Concrete DependenciesSmall Action MethodsDon’t mix HttpVerbsAvoid magic stringsUse controller as a traffic flow managerUnit test your expectationsAll the public methods are web accessibleUse OutputCacheBest Practices on Controller
  • 30. Define Views in an enum:return View(viewNames.Index);Even Better use T4MVCView.ModelMVCContrib for RedirectToAction:return RedirectToAction<HomeController>(c=>c.Index)Removing Magics in Controller
  • 31. Refactor View Names and Links with T4MVCCache the outputWrite simple unit testDEMO
  • 32. Dependency Injectionprivate IBookRepositorybookRepository;public HomeController(){bookRepository = new BookRepository();} What if BookRepository has dependencies?
  • 33. Is it HomeContoller’s job to satisfy dependencies?
  • 34. Why does Home Controller have to know about BookRepository()?
  • 35. What if HomeController needs initialization param in the constructor?private IBookRepositorybookRepository;public HomeController(IBookRepository repo){bookRepository = repo;} But who calls the controller with a parameterized constructor? NOT MVC Framework, at least not the default ControllerFactoryBetter Injection
  • 36. Extend ControllerFactoryUse one of the IOC frameworks:StructureMap, Ninject, Windsor etc…Even Better Injection
  • 38. No Magic String (use T4MVC)Change ../ pathsStrongly Typed ViewRenderPartialHtmlHelpersUse HTML if you canIf there is an “If” , time to check HtmlHelpersEncode input stringBest Practices On View
  • 40. Separate ControllersUse IoCNo Business Logic in ControllersNo Magic Strings in any componentUse HTML HelpersDRYTestStrongly Types ViewsList of Practices
  • 41. Client side validation with JQueryTemplatingStrongly typed helpersAreas SupportAsync Controller ActionsNew Things With MVC 2
  • 42. Thanks to Jonas Follesø (http://jonas.follesoe.no)Thank you

Editor's Notes

  • #18: Use Repository Pattern Separate the Model layer from Control layerMVC is in presentation layer, model is in persistence layerDon’t let your UI talk to business model directlyUse orm, orm is not for only if I change the db later…
  • #22: Use automapper, silverlight and wpf has binding support , and mvvm support