SlideShare une entreprise Scribd logo
1  sur  34
ASP.NET MVC VolkanUzun
Web Developer at California State University, San Bernardino MS. Computer Science, MCP, and MCTS Interest Areas: TDD, Web Programming, Secure Coding User group maniac, visiting many user groups in a month Blog: http://www.msnetprogrammer.net/blog, Email: volkan@iedotnetug.org Twitter: http://www.twitter.com/volkanuzun About Me
Classic ASP (Another Slow Page!?) .NET Framework (Hurraay!!) ASP.NET v1.0 (No more slow pages) ASP.NET v1.1 ASP.NET v2.0 ASP.NET Ajax  ASP.NET 3.5 Silverlight ?!?! ASP.NET MVC ASP.NET WebForms 4.0 …. MS Web Developer History
Easy to learn but? Maintenance? Test? Debugging? Complexity? What was wrong with ASP?
Desktop like programming paradigm Lot’s of out ofbox controls No more spaghetti code? ASP.NET Web Forms
ViewState (supposed to    help you but?) DRY Can’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
MVC Different 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 Reenskaug The model is the domain-specific representation of the data upon which the application operates The controller receives input and initiates a response by making calls on model objects. The view renders the model into a form suitable for interaction Wikipedia: MVC
[object Object]
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 Postback Very 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 others Why 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/List Route is selected Controller is activated (Products) Controller executes the action method (List) Action talks to Model, prepares the ViewData Action renders View But what is it?
Located in Controllers folder, You can change it derived from Controller base class The class name should be controller name + “Controller” Action Methods does the work Delete AccountController Move Controller’s to a separate project Controller
The ambiguous part of ASP.NET MVC M is the only part of MVC that is not implemented in ASP.NET MVC View Model: How your data looks on the page, flat data Domain Model: How your business data is, hierarchical data Any ORM is fine MODEL
Just renders the page, no biz logic!!! No ViewState, no server controls NO Codebehind, pls DON’T Default ViewEngine is WebForms Communicates with Controller with ViewData Dictionary Strongly Typed View VIEW
FILE => NEW… Project Structure
Separate Domain Model and View Model Use an ORM Use Repository Pattern Domain Model should only validate domain rules Presentation layer should NOT  care about persistence layer Best Practices on Model
FALSE ViewModel == DomainModel The most annoying part of Presentation Model is the synchronization between Presentation Model and view… Martin Fowler, GUI Architectures Essay, July 2004
Music Store App Display Albums Display Customers Refactor the Model Use AutoMapper DEMO
No Business Logic No Concrete Dependencies Small Action Methods Don’t mix HttpVerbs Avoid magic strings Use controller as a traffic flow manager Unit test your expectations All the public methods are web accessible Use OutputCache Best Practices on Controller
Define Views in an enum:return View(viewNames.Index); Even Better use T4MVC View.Model MVCContrib for RedirectToAction:return RedirectToAction<HomeController>(c=>c.Index) Removing Magics in Controller
Refactor View Names and Links with T4MVC Cache the output Write simple unit test DEMO
Dependency Injection private IBookRepositorybookRepository;public HomeController(){bookRepository = new BookRepository();} ,[object Object]
 Is it HomeContoller’s job to satisfy dependencies?
 Why does Home Controller have to know about BookRepository()?

Contenu connexe

Tendances (20)

ASP.NET MVC.
ASP.NET MVC.ASP.NET MVC.
ASP.NET MVC.
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
Model View Controller (MVC)
Model View Controller (MVC)Model View Controller (MVC)
Model View Controller (MVC)
 
Spring MVC Framework
Spring MVC FrameworkSpring MVC Framework
Spring MVC Framework
 
React workshop
React workshopReact workshop
React workshop
 
Spring MVC
Spring MVCSpring MVC
Spring MVC
 
ReactJS presentation.pptx
ReactJS presentation.pptxReactJS presentation.pptx
ReactJS presentation.pptx
 
Asp.net.
Asp.net.Asp.net.
Asp.net.
 
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
 
Intro to React
Intro to ReactIntro to React
Intro to React
 
Mvc architecture
Mvc architectureMvc architecture
Mvc architecture
 
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
 
ASP .net MVC
ASP .net MVCASP .net MVC
ASP .net MVC
 
Angular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP ServicesAngular - Chapter 7 - HTTP Services
Angular - Chapter 7 - HTTP Services
 
Angular 8
Angular 8 Angular 8
Angular 8
 
[Final] ReactJS presentation
[Final] ReactJS presentation[Final] ReactJS presentation
[Final] ReactJS presentation
 
reactJS
reactJSreactJS
reactJS
 
Its time to React.js
Its time to React.jsIts time to React.js
Its time to React.js
 
MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )MVVM ( Model View ViewModel )
MVVM ( Model View ViewModel )
 
Why MVC?
Why MVC?Why MVC?
Why MVC?
 

En vedette

En vedette (6)

.NET and C# Introduction
.NET and C# Introduction.NET and C# Introduction
.NET and C# Introduction
 
C# basics
 C# basics C# basics
C# basics
 
C# Tutorial
C# Tutorial C# Tutorial
C# Tutorial
 
C#.NET
C#.NETC#.NET
C#.NET
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Introduction to .net framework
Introduction to .net frameworkIntroduction to .net framework
Introduction to .net framework
 

Similaire à ASP.NET MVC Presentation

Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To MvcVolkan Uzun
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCBarry 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.0Shiju 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 GuideAlicia 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 mvcUmar 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.0Shiju Varghese
 
Deep Dive: MVC Controller Architecture
Deep Dive: MVC Controller ArchitectureDeep Dive: MVC Controller Architecture
Deep Dive: MVC Controller ArchitectureChris Eargle
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC StructureDipika 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.netConcetto 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 - IndiandotnetIndiandotnet
 
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 MVCshobokshi
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Railscodeinmotion
 

Similaire à ASP.NET MVC Presentation (20)

Introduction To Mvc
Introduction To MvcIntroduction To Mvc
Introduction To Mvc
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVCCTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
 
Asp.Net MVC Intro
Asp.Net MVC IntroAsp.Net MVC Intro
Asp.Net MVC Intro
 
ASP.NET MVC 3
ASP.NET MVC 3ASP.NET MVC 3
ASP.NET MVC 3
 
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
 
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
 
Php and-mvc
Php and-mvcPhp and-mvc
Php and-mvc
 
Asp.netmvc handson
Asp.netmvc handsonAsp.netmvc handson
Asp.netmvc handson
 
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
 
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
 
No brainer
No brainerNo brainer
No brainer
 
Deep Dive: MVC Controller Architecture
Deep Dive: MVC Controller ArchitectureDeep Dive: MVC Controller Architecture
Deep Dive: MVC Controller Architecture
 
Ppt of Basic MVC Structure
Ppt of Basic MVC StructurePpt of Basic MVC Structure
Ppt of Basic MVC Structure
 
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
 
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
 
Asp.net mvc
Asp.net mvcAsp.net mvc
Asp.net mvc
 
ASP .NET MVC
ASP .NET MVC ASP .NET MVC
ASP .NET MVC
 
Beyond The MVC
Beyond The MVCBeyond The MVC
Beyond The MVC
 
Getting Started with ASP.NET MVC
Getting Started with ASP.NET MVCGetting Started with ASP.NET MVC
Getting Started with ASP.NET MVC
 
MVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on RailsMVC Demystified: Essence of Ruby on Rails
MVC Demystified: Essence of Ruby on Rails
 

Dernier

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEarley Information Science
 
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...Drew Madelung
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking MenDelhi Call girls
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationRadu Cotescu
 
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 CVKhem
 
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...Martijn de Jong
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountPuma Security, LLC
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 

Dernier (20)

🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptxEIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
EIS-Webinar-Prompt-Knowledge-Eng-2024-04-08.pptx
 
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...
 
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
08448380779 Call Girls In Diplomatic Enclave Women Seeking Men
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
 
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
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
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
 
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...
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
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
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
Breaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path MountBreaking the Kubernetes Kill Chain: Host Path Mount
Breaking the Kubernetes Kill Chain: Host Path Mount
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 

ASP.NET MVC Presentation

  • 2. Web Developer at California State University, San Bernardino MS. Computer Science, MCP, and MCTS Interest Areas: TDD, Web Programming, Secure Coding User group maniac, visiting many user groups in a month Blog: http://www.msnetprogrammer.net/blog, Email: volkan@iedotnetug.org Twitter: http://www.twitter.com/volkanuzun About Me
  • 3.
  • 4. Classic ASP (Another Slow Page!?) .NET Framework (Hurraay!!) ASP.NET v1.0 (No more slow pages) ASP.NET v1.1 ASP.NET v2.0 ASP.NET Ajax ASP.NET 3.5 Silverlight ?!?! ASP.NET MVC ASP.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 paradigm Lot’s of out ofbox controls No more spaghetti code? ASP.NET Web Forms
  • 7. ViewState (supposed to help you but?) DRY Can’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. MVC Different 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 Reenskaug The model is the domain-specific representation of the data upon which the application operates The controller receives input and initiates a response by making calls on model objects. The view renders the model into a form suitable for interaction Wikipedia: MVC
  • 11.
  • 13. Giving you more control over html.
  • 14. An easier to test framework.
  • 15. Another option to web development.
  • 18. No View State, No Postback Very 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 others Why 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/List Route is selected Controller is activated (Products) Controller executes the action method (List) Action talks to Model, prepares the ViewData Action renders View But what is it?
  • 22. Located in Controllers folder, You can change it derived from Controller base class The class name should be controller name + “Controller” Action Methods does the work Delete AccountController Move Controller’s to a separate project Controller
  • 23. The ambiguous part of ASP.NET MVC M is the only part of MVC that is not implemented in ASP.NET MVC View Model: How your data looks on the page, flat data Domain Model: How your business data is, hierarchical data Any ORM is fine MODEL
  • 24. Just renders the page, no biz logic!!! No ViewState, no server controls NO Codebehind, pls DON’T Default ViewEngine is WebForms Communicates with Controller with ViewData Dictionary Strongly Typed View VIEW
  • 25. FILE => NEW… Project Structure
  • 26. Separate Domain Model and View Model Use an ORM Use Repository Pattern Domain Model should only validate domain rules Presentation layer should NOT care about persistence layer Best Practices on Model
  • 27. FALSE ViewModel == DomainModel The most annoying part of Presentation Model is the synchronization between Presentation Model and view… Martin Fowler, GUI Architectures Essay, July 2004
  • 28. Music Store App Display Albums Display Customers Refactor the Model Use AutoMapper DEMO
  • 29. No Business Logic No Concrete Dependencies Small Action Methods Don’t mix HttpVerbs Avoid magic strings Use controller as a traffic flow manager Unit test your expectations All the public methods are web accessible Use OutputCache Best Practices on Controller
  • 30. Define Views in an enum:return View(viewNames.Index); Even Better use T4MVC View.Model MVCContrib for RedirectToAction:return RedirectToAction<HomeController>(c=>c.Index) Removing Magics in Controller
  • 31. Refactor View Names and Links with T4MVC Cache the output Write simple unit test DEMO
  • 32.
  • 33. Is it HomeContoller’s job to satisfy dependencies?
  • 34. Why does Home Controller have to know about BookRepository()?
  • 35.
  • 36. Extend ControllerFactory Use one of the IOC frameworks:StructureMap, Ninject, Windsor etc… Even Better Injection
  • 38. No Magic String (use T4MVC) Change ../ paths Strongly Typed View RenderPartial HtmlHelpers Use HTML if you can If there is an “If” , time to check HtmlHelpers Encode input string Best Practices On View
  • 40. Separate Controllers Use IoC No Business Logic in Controllers No Magic Strings in any component Use HTML Helpers DRY Test Strongly Types Views List of Practices
  • 41. Client side validation with JQuery Templating Strongly typed helpers Areas Support Async Controller Actions New Things With MVC 2
  • 42. Thanks to Jonas Follesø (http://jonas.follesoe.no) Thank you

Notes de l'éditeur

  1. 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…
  2. Use automapper, silverlight and wpf has binding support , and mvvm support