SlideShare a Scribd company logo
ASP.net MVC Owen Evans Developer, Xero
or
Welcome to the new (old) way MVC – Model-View-Controller About architectural separation Not a new pattern, first attributed to Trygve Reenskaug, working in smalltalk at Xerox Parc Convention over configuration Less to think about (no page object model) Easier to unit test
Lots of MVC Frameworks Some well known: Rails, Merb, Monorail, Grails, Spring MVC Framework, Dojo, Django, Silverstripe, Flex, Swing,  Others not so Check Wikipedia for links to lots of frameworks
The MVC pattern Controller View Model
MVC vs. Classic ASP.net ASP.net Classic ASP.net MVC
Model The computer model. The representation of the system within your application domain Business objects, services, data access etc The application core
Controllers Direct all the action of a request Make calls to models to gather data Sends business object and information to a particular view. Makes decisions for security, UI, redirects etc. Provides the glue between the mental model and the computer model
A Basic Controller public class HomeController : Controller { public ActionResult Index() {   var message = someService.GetAMessage() return View(message); } } Interacts with the model and gets a message Puts the message to the default view Only one action/view for this controller
View Responsible for displaying a given expectation of data. Will interact with model but shouldn’t make decisions over what entities to display, shouldn’t make CRUD actions etc. Purely about representing the mental model of the system. Not restricted to aspx, can also use Nhaml, Brail, XSLT to name but a few, just implement a ViewEngine if you want your own view syntax
A Basic View <%@ Page Language=&quot;C#&quot; MasterPageFile=&quot;~/Views/Shared/Site.Master&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Index.aspx.cs&quot; Inherits=&quot;Basic_MVC_Project.Views.Home.Index&quot; %> <asp:Content ID=&quot;indexContent&quot; ContentPlaceHolderID=&quot;MainContent&quot; runat=&quot;server&quot;> <h2><%= Html.Encode(ViewData[&quot;Message&quot;]) %></h2> <p> To learn more about ASP.NET MVC visit <a href=&quot;http://asp.net/mvc&quot; title=&quot;ASP.NET MVC Website&quot;>http://asp.net/mvc</a>. </p> </asp:Content> Relies on a master page Just displays the data in the ViewData store
Putting the R in MVC Routing is part of the major power of MVC Many URLs can link to the same controller, unlike code behinds which have a 1-1 link with .aspx pages, controllers can have multiple views Controllers are usually grouped around conceptual objects within the domain Tasks, Posts, Products
The ActionResult The key to actions is ActionResult which has many implementations ViewResult:  Renders the specified view to the response. EmptyResult:  Does nothing. Returned if the action method must return a null result. RedirectResult:  Performs an HTTP redirect to the specified URL. RedirectToRouteResult:  Given some routing values, uses the routing API to determine the URL and then redirects to that URL. JsonResult:  Serializes the specified ViewData object to JSON format. ContentResult:  Writes the specified text content to the response.
ActionFilter Attribute based interception of action calls Can hook into calls: OnActionExecuted OnActionExecuting OnResultExecuted OnResultExecuting Useful for logging, security, caching etc.
Extras Ajax made easy You can just return a Json result and JavaScript can eval the response to get the result. REST made easy Routing makes creating rest web services just a case of routing to the correct action
Caveats This talk was based on Preview 4, Preview 5 was released on Friday and has a couple of minor changes Preview code still, API’s are subject to change. Still a lot of community work to do to create helpers, utilities etc..
Questions? Ask Scott Hanselman……. Contact me: http://www.bgeek.net,  owen@bgeek.net,  http://www.twitter.com/buildmaster
References ASP.net MVC Official Site  http://www.asp.net/mvc/ MVC Xerox Parc  http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html Scott Gu, Phil Haack, Scott Hanselman, Rob Conery  http://weblogs.asp.net/scottgu/  http://haacked.com/Default.aspx  http://www.hanselman.com/  http://blog.wekeroad.com/  MVC Contrib Project   http://codeplex.com/MVCContrib

More Related Content

What's hot (20)

Web&java. jsp
Web&java. jsp
Asya Dudnik
 
Shaping up with angular JS
Shaping up with angular JS
Brajesh Yadav
 
What's new in asp.net mvc 4
What's new in asp.net mvc 4
Simone Chiaretta
 
AngularJS in 60ish Minutes
AngularJS in 60ish Minutes
Dan Wahlin
 
AngularJS Introduction
AngularJS Introduction
Brajesh Yadav
 
Directives
Directives
Brajesh Yadav
 
Controller in AngularJS
Controller in AngularJS
Brajesh Yadav
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
Simon Guest
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
Olga Lavrentieva
 
Developing web apps using Java and the Play framework
Developing web apps using Java and the Play framework
Victor Porof
 
Introduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
Content as a Service with Umbraco Headless
Content as a Service with Umbraco Headless
Filip Bruun Bech-Larsen
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
LearnNowOnline
 
AngularJS best-practices
AngularJS best-practices
Henry Tao
 
Asp.net mvc
Asp.net mvc
erdemergin
 
Kickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with Yeoman
Patrick Buergin
 
ASP.NET MVC and ajax
ASP.NET MVC and ajax
Brij Mishra
 
Angular Presentation
Angular Presentation
Adam Moore
 
Angularjs Basics
Angularjs Basics
Anuradha Bandara
 
Dive into AngularJS and directives
Dive into AngularJS and directives
Tricode (part of Dept)
 
Shaping up with angular JS
Shaping up with angular JS
Brajesh Yadav
 
What's new in asp.net mvc 4
What's new in asp.net mvc 4
Simone Chiaretta
 
AngularJS in 60ish Minutes
AngularJS in 60ish Minutes
Dan Wahlin
 
AngularJS Introduction
AngularJS Introduction
Brajesh Yadav
 
Controller in AngularJS
Controller in AngularJS
Brajesh Yadav
 
Advanced Tips & Tricks for using Angular JS
Advanced Tips & Tricks for using Angular JS
Simon Guest
 
Angular.js опыт использования, проблемы и решения
Angular.js опыт использования, проблемы и решения
Olga Lavrentieva
 
Developing web apps using Java and the Play framework
Developing web apps using Java and the Play framework
Victor Porof
 
Introduction of ASP.NET MVC and AngularJS
Introduction of ASP.NET MVC and AngularJS
Mohamed Elkhodary
 
Content as a Service with Umbraco Headless
Content as a Service with Umbraco Headless
Filip Bruun Bech-Larsen
 
Introduction to ASP.NET MVC
Introduction to ASP.NET MVC
LearnNowOnline
 
AngularJS best-practices
AngularJS best-practices
Henry Tao
 
Kickstarting Node.js Projects with Yeoman
Kickstarting Node.js Projects with Yeoman
Patrick Buergin
 
ASP.NET MVC and ajax
ASP.NET MVC and ajax
Brij Mishra
 
Angular Presentation
Angular Presentation
Adam Moore
 

Similar to ASP.net MVC CodeCamp Presentation (20)

Introduction To Mvc
Introduction To Mvc
Volkan Uzun
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
denemedeniz
 
Introduction to ASP.Net MVC
Introduction to ASP.Net MVC
Sagar Kamate
 
Asp.Net MVC Intro
Asp.Net MVC Intro
Stefano Paluello
 
MVC 4
MVC 4
Vasilios Kuznos
 
ASP.NET MVC 2.0
ASP.NET MVC 2.0
Buu Nguyen
 
ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)
Hatem Hamad
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
Barry Gervin
 
Asp 1-mvc introduction
Asp 1-mvc introduction
Fajar Baskoro
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
maddinapudi
 
ASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
 
ASP.NET MVC Presentation
ASP.NET MVC Presentation
ivpol
 
ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1
Gaurav Arora
 
Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1
Gaurav Arora
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
Asp.Net MVC3 - Basics
Asp.Net MVC3 - Basics
Saravanan Subburayal
 
MVC Framework
MVC Framework
Ashton Feller
 
Asp.Net Mvc
Asp.Net Mvc
micham
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive jinal desai
jinaldesailive
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
Thomas Robbins
 
Introduction To Mvc
Introduction To Mvc
Volkan Uzun
 
Hanselman lipton asp_connections_ams304_mvc
Hanselman lipton asp_connections_ams304_mvc
denemedeniz
 
Introduction to ASP.Net MVC
Introduction to ASP.Net MVC
Sagar Kamate
 
ASP.NET MVC 2.0
ASP.NET MVC 2.0
Buu Nguyen
 
ASP.net MVC Introduction Wikilogia (nov 2014)
ASP.net MVC Introduction Wikilogia (nov 2014)
Hatem Hamad
 
CTTDNUG ASP.NET MVC
CTTDNUG ASP.NET MVC
Barry Gervin
 
Asp 1-mvc introduction
Asp 1-mvc introduction
Fajar Baskoro
 
Asp.Net MVC Framework Design Pattern
Asp.Net MVC Framework Design Pattern
maddinapudi
 
ASP.NET MVC introduction
ASP.NET MVC introduction
Tomi Juhola
 
ASP.NET MVC Presentation
ASP.NET MVC Presentation
ivpol
 
ASPNet MVC series for beginers part 1
ASPNet MVC series for beginers part 1
Gaurav Arora
 
Asp net mvc series for beginers part 1
Asp net mvc series for beginers part 1
Gaurav Arora
 
Asp.net mvc presentation by Nitin Sawant
Asp.net mvc presentation by Nitin Sawant
Nitin S
 
Asp.Net Mvc
Asp.Net Mvc
micham
 
Mvc interview questions – deep dive jinal desai
Mvc interview questions – deep dive jinal desai
jinaldesailive
 
Getting started with MVC 5 and Visual Studio 2013
Getting started with MVC 5 and Visual Studio 2013
Thomas Robbins
 
Ad

More from buildmaster (7)

DevOps is Dead. Long live devops
DevOps is Dead. Long live devops
buildmaster
 
API Days: For the Love of Small
API Days: For the Love of Small
buildmaster
 
MEFilicious Applications
MEFilicious Applications
buildmaster
 
Bahaviour Driven Development
Bahaviour Driven Development
buildmaster
 
Linq Refresher
Linq Refresher
buildmaster
 
Oslo
Oslo
buildmaster
 
Mocking 101
Mocking 101
buildmaster
 
DevOps is Dead. Long live devops
DevOps is Dead. Long live devops
buildmaster
 
API Days: For the Love of Small
API Days: For the Love of Small
buildmaster
 
MEFilicious Applications
MEFilicious Applications
buildmaster
 
Bahaviour Driven Development
Bahaviour Driven Development
buildmaster
 
Ad

Recently uploaded (20)

Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 
Edge-banding-machines-edgeteq-s-200-en-.pdf
Edge-banding-machines-edgeteq-s-200-en-.pdf
AmirStern2
 
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
“Why It’s Critical to Have an Integrated Development Methodology for Edge AI,...
Edge AI and Vision Alliance
 
Artificial Intelligence in the Nonprofit Boardroom.pdf
Artificial Intelligence in the Nonprofit Boardroom.pdf
OnBoard
 
Oracle Cloud Infrastructure AI Foundations
Oracle Cloud Infrastructure AI Foundations
VICTOR MAESTRE RAMIREZ
 
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Reducing Conflicts and Increasing Safety Along the Cycling Networks of East-F...
Safe Software
 
Enabling BIM / GIS integrations with Other Systems with FME
Enabling BIM / GIS integrations with Other Systems with FME
Safe Software
 
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
Can We Use Rust to Develop Extensions for PostgreSQL? (POSETTE: An Event for ...
NTT DATA Technology & Innovation
 
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
Your startup on AWS - How to architect and maintain a Lean and Mean account J...
angelo60207
 
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Seminar: Evolving Landscape of Post-Quantum Cryptography.pptx
FIDO Alliance
 
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance Seminar State of Passkeys.pptx
FIDO Alliance
 
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
“From Enterprise to Makers: Driving Vision AI Innovation at the Extreme Edge,...
Edge AI and Vision Alliance
 
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Seminar: Targeting Trust: The Future of Identity in the Workforce.pptx
FIDO Alliance
 
Supporting the NextGen 911 Digital Transformation with FME
Supporting the NextGen 911 Digital Transformation with FME
Safe Software
 
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
FME for Good: Integrating Multiple Data Sources with APIs to Support Local Ch...
Safe Software
 
Murdledescargadarkweb.pdfvolumen1 100 elementary
Murdledescargadarkweb.pdfvolumen1 100 elementary
JorgeSemperteguiMont
 
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
No-Code Workflows for CAD & 3D Data: Scaling AI-Driven Infrastructure
Safe Software
 
Oracle Cloud and AI Specialization Program
Oracle Cloud and AI Specialization Program
VICTOR MAESTRE RAMIREZ
 
Bridging the divide: A conversation on tariffs today in the book industry - T...
Bridging the divide: A conversation on tariffs today in the book industry - T...
BookNet Canada
 
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Viral>Wondershare Filmora 14.5.18.12900 Crack Free Download
Puppy jhon
 
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
vertical-cnc-processing-centers-drillteq-v-200-en.pdf
AmirStern2
 

ASP.net MVC CodeCamp Presentation

  • 1. ASP.net MVC Owen Evans Developer, Xero
  • 2. or
  • 3. Welcome to the new (old) way MVC – Model-View-Controller About architectural separation Not a new pattern, first attributed to Trygve Reenskaug, working in smalltalk at Xerox Parc Convention over configuration Less to think about (no page object model) Easier to unit test
  • 4. Lots of MVC Frameworks Some well known: Rails, Merb, Monorail, Grails, Spring MVC Framework, Dojo, Django, Silverstripe, Flex, Swing, Others not so Check Wikipedia for links to lots of frameworks
  • 5. The MVC pattern Controller View Model
  • 6. MVC vs. Classic ASP.net ASP.net Classic ASP.net MVC
  • 7. Model The computer model. The representation of the system within your application domain Business objects, services, data access etc The application core
  • 8. Controllers Direct all the action of a request Make calls to models to gather data Sends business object and information to a particular view. Makes decisions for security, UI, redirects etc. Provides the glue between the mental model and the computer model
  • 9. A Basic Controller public class HomeController : Controller { public ActionResult Index() { var message = someService.GetAMessage() return View(message); } } Interacts with the model and gets a message Puts the message to the default view Only one action/view for this controller
  • 10. View Responsible for displaying a given expectation of data. Will interact with model but shouldn’t make decisions over what entities to display, shouldn’t make CRUD actions etc. Purely about representing the mental model of the system. Not restricted to aspx, can also use Nhaml, Brail, XSLT to name but a few, just implement a ViewEngine if you want your own view syntax
  • 11. A Basic View <%@ Page Language=&quot;C#&quot; MasterPageFile=&quot;~/Views/Shared/Site.Master&quot; AutoEventWireup=&quot;true&quot; CodeBehind=&quot;Index.aspx.cs&quot; Inherits=&quot;Basic_MVC_Project.Views.Home.Index&quot; %> <asp:Content ID=&quot;indexContent&quot; ContentPlaceHolderID=&quot;MainContent&quot; runat=&quot;server&quot;> <h2><%= Html.Encode(ViewData[&quot;Message&quot;]) %></h2> <p> To learn more about ASP.NET MVC visit <a href=&quot;http://asp.net/mvc&quot; title=&quot;ASP.NET MVC Website&quot;>http://asp.net/mvc</a>. </p> </asp:Content> Relies on a master page Just displays the data in the ViewData store
  • 12. Putting the R in MVC Routing is part of the major power of MVC Many URLs can link to the same controller, unlike code behinds which have a 1-1 link with .aspx pages, controllers can have multiple views Controllers are usually grouped around conceptual objects within the domain Tasks, Posts, Products
  • 13. The ActionResult The key to actions is ActionResult which has many implementations ViewResult: Renders the specified view to the response. EmptyResult: Does nothing. Returned if the action method must return a null result. RedirectResult: Performs an HTTP redirect to the specified URL. RedirectToRouteResult: Given some routing values, uses the routing API to determine the URL and then redirects to that URL. JsonResult: Serializes the specified ViewData object to JSON format. ContentResult: Writes the specified text content to the response.
  • 14. ActionFilter Attribute based interception of action calls Can hook into calls: OnActionExecuted OnActionExecuting OnResultExecuted OnResultExecuting Useful for logging, security, caching etc.
  • 15. Extras Ajax made easy You can just return a Json result and JavaScript can eval the response to get the result. REST made easy Routing makes creating rest web services just a case of routing to the correct action
  • 16. Caveats This talk was based on Preview 4, Preview 5 was released on Friday and has a couple of minor changes Preview code still, API’s are subject to change. Still a lot of community work to do to create helpers, utilities etc..
  • 17. Questions? Ask Scott Hanselman……. Contact me: http://www.bgeek.net, [email protected], http://www.twitter.com/buildmaster
  • 18. References ASP.net MVC Official Site http://www.asp.net/mvc/ MVC Xerox Parc http://heim.ifi.uio.no/~trygver/themes/mvc/mvc-index.html Scott Gu, Phil Haack, Scott Hanselman, Rob Conery http://weblogs.asp.net/scottgu/ http://haacked.com/Default.aspx http://www.hanselman.com/ http://blog.wekeroad.com/ MVC Contrib Project http://codeplex.com/MVCContrib