SlideShare a Scribd company logo
Introducing ASP.NET MVC Alan Dean, Senior Technologist
Model-View-Controller (MVC) is a well-known design pattern The original 1978 implementation is described in depth in the influential 1992 paper “ Applications Programming in Smalltalk-80: How to use Model-View-Controller (MVC)” by Steve Burbeck
…“ the concept of the design pattern in software provides a key to helping developers leverage the expertise of other skilled architects.” Grady Booch, 1995
 
MVC consists of three kinds of objects The  Model  is the application object The  View  is the screen presentation The  Controller   defines the way the user interface reacts to user input
Before MVC, user interface designs tended to lump these objects together MVC decouples them to increase flexibility and reuse
Controller Model View
In his paper Steve Burbeck describes two variations of MVC a  passive  model and an active model
The passive model is employed when one controller manipulates the model exclusively The controller modifies the model and then informs the view that the model has changed and should be refreshed The model in this scenario is completely independent of the view and the controller, which means that there is no means for the model to report changes in its state
Controller View Model handleEvent service update getData
The HTTP protocol is an example of this. The browser displays the view and responds to user input, but it does not detect changes in the data on the server. Only when the browser explicitly requests a refresh is the server interrogated for changes.
Separation of Concerns (SoC) Object types become ‘pluggable’ Intra-team dependency is reduced Testability  is enhanced Application flow can be hard to grok
MVC Web Frameworks Java has  Swing ,  Struts ,  Grails  and others Perl has  Catalyst ,  Gantry ,  Jifty  and others PHP has  Zend ,  Zoop ,  Agavi  and others Python has  Django ,  Gluon ,  Pylon  and others Ruby on Rails  is famously ‘opinionated’ …  and .NET?
.NET MVC Web Frameworks Spring.NET http://www.springframework.net/ Maverick.NET http://mavnet.sourceforge.net/ MonoRail http://www.castleproject.org/monorail/ …  and now ASP.NET MVC from Microsoft http://asp.net/downloads/3.5-extensions/
“ The ASP.NET MVC framework is a lightweight, highly testable presentation framework that is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc namespace and is a fundamental, supported part of the System.Web namespace”
Demo Create a new ASP.NET MVC Solution
HTTP Request Flow HTTP Response GET /Home/Index HTTP/1.1 HTTP Request Route Handler Controller Model View
HTTP Request Flow public class   Global  :  HttpApplication { protected void  Application_Start( object  sender,  EventArgs  e) { RouteTable .Routes.Add( new   Route { Url =  "[controller]/[action]/[id]" , Defaults =  new  { action =  "Index" , id = ( string ) null  }, RouteHandler =  typeof ( MvcRouteHandler ) }); } } HTTP Response Route Handler HTTP Request Controller Model View
HTTP Request Flow public class   HomeController  :  Controller { [ ControllerAction ] public void  Index() { CompanyInfo  companyInfo =  new   CompanyInfo (); companyInfo.CompanyName =  "Your company name here" ; RenderView( "Index" , companyInfo); } } HTTP Response Controller HTTP Request Route Handler Model View
HTTP Request Flow public class   CompanyInfo { public string  CompanyName {  get ;  set ; } } HTTP Response Model HTTP Request Route Handler Controller View
HTTP Request Flow public partial class   Index  :  ViewPage < CompanyInfo > { } Response View <% @  Page   Language =&quot;C#&quot;  AutoEventWireup =&quot;true&quot;  CodeBehind =&quot;Index.aspx.cs&quot;  Inherits =&quot;MvcApplication.Views.Home.Index&quot;  %> < html > < head > < title > <%= this.ViewData.companyName %> </ title > </ head > < body > <%= Html.ActionLink( “Homepage&quot; ,  &quot;Index&quot; ,  &quot;Home&quot; ) %> < div > Welcome! </ div > </ body > </ html > HTTP Request Route Handler Controller Model
HTTP Request Flow HTTP/1.1 200 OK Content-Type: text/html <html> <head> <title>Your company name here</title> </head> <body> <a href=&quot;/Home/Index&quot;>Index</a> <div>Welcome!</div> </body> </html> HTTP Request Route Handler Controller Model View HTTP Response
Wiki A wiki is software that allows users to create, edit, and link web pages easily
Ward Cunningham, developer of the first wiki,  WikiWikiWeb , originally described it as &quot;the simplest online database that could possibly work&quot;
Wiki Database CREATE TABLE  [dbo].[PageTable] ( [Id]  int IDENTITY (1,1)  NOT NULL , [Guid]  uniqueidentifier NOT NULL , [LastModified]  datetime NOT NULL , [Removed]  datetime NULL , [Title]  varchar (255)  NOT NULL , [Body]  ntext NOT NULL );
Wiki HTTP API GET / GET /page.html POST /page GET /page/[title] GET /page/[title].txt GET /page/[title].html GET /page/[title].atom PUT /page/[title] DELETE /page/[title]
GET The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. Safe  &  Idempotent
GET / Accept: text/html, */* 303 See Other Location: http://localhost/page.html Cache-Control: public Expires: Thu, 31 Jan 2008 16:00:00 GMT
GET /page.html Accept: text/html, */* 200 OK Content-Type: text/html Cache-Control: public Expires: Thu, 31 Jan 2008 16:00:00 GMT <html> <head><title>…</title></head> <body> <form action=&quot; /page &quot; method=&quot; post &quot; enctype=&quot; application/x-www-form-urlencoded &quot;> <input type=&quot;text&quot; name=&quot;title&quot; maxlength=&quot;255&quot; /> <textarea name=&quot;body&quot; rows=&quot;25&quot; cols=&quot;80&quot;></textarea> <input type=&quot;submit&quot; value=&quot;Create Page&quot; /> </form> </body> </html>
POST The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI
POST /page Content-Type: application/x-www-form-urlencoded title=Welcome&body=Welcome+to+my+new+wiki. 201 Created Content-Type: text/html Content-Location: http://localhost/page/Welcome Cache-Control: no-cache <html> <head> <title>…</title> <meta http-equiv=&quot; refresh &quot;   content=&quot;0;url= http://localhost:64701/page/Welcome &quot;> </head> <body>…</body> </html>
GET /page/Welcome Accept: text/html, */* 303 See Other Location: http://localhost/page/Welcome.html Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT Vary: Accept
GET /page/Welcome.html Accept: text/html, */* 200 OK Content-Type: text/html Content-Location: http://localhost/page/Welcome Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT <html> <head> <title>…</title> <link href=&quot; http://localhost/page/Welcome.atom &quot; rel=&quot; alternate &quot; title=&quot;…&quot; type=&quot; application/atom+xml &quot; /> </head> <body>…</body> </html>
GET /page/Welcome.atom Accept: application/atom+xml 200 OK Content-Type: application/atom+xml Content-Location: http://localhost/page/Welcome Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT <?xml version=&quot;1.0&quot; encoding=&quot;utf-8”?> <feed xml:lang=&quot;en&quot; xmlns=&quot;http://www.w3.org/2005/Atom&quot;> … <link href=&quot; http://localhost:64701/page/Welcome &quot; rel=&quot; source &quot; /> <link href=&quot; http://localhost:64701/page/Welcome.atom &quot; rel=&quot; self &quot; type=&quot;application/atom+xml&quot; hreflang=&quot;en&quot; title=&quot;…&quot; /> <link href=&quot; http://localhost:64701/page/Welcome.html &quot; rel=&quot; alternate &quot; type=&quot;text/html&quot; hreflang=&quot;en&quot; title=&quot;…&quot; /> <link href=&quot; http://localhost:64701/page/Welcome.txt &quot; rel=&quot; alternate &quot; type=&quot;text/plain&quot; hreflang=&quot;en&quot; title=&quot;…&quot; /> <entry>…</entry> </feed>
GET /page/Welcome Accept: text/plain 303 See Other Location: http://localhost/page/Welcome.txt Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT Vary: Accept GET /page/Welcome.txt Accept: text/plain 200 OK Content-Type: text/plain Content-Location: http://localhost/page/Welcome Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT Welcome to my new wiki.
PUT The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. Idempotent
PUT /page/Welcome Content-Type: text/plain Welcome to my new [[wiki]]. 204 No Content Cache-Control: no-cache
DELETE The DELETE method requests that the origin server delete the resource identified by the Request-URI. Idempotent
DELETE /page/Welcome 204 No Content Cache-Control: no-cache
 
RE presentational  S tate  T ransfer
REST: The Web Used Correctly A system or application architecture …  that uses HTTP, URI and other Web standards “correctly” …  is “on” the Web, not tunnelled through it
REST is an Architectural Style Defines a set of key “constraints” …  that, if met, make an architecture “RESTful” …  with the Web as one example
Equate “REST” with “RESTful HTTP usage” Stefan Tilkov
Deriving REST Client-Server Stateless Cache Uniform interface Layered system Code on Demand
“ The central feature that distinguishes the REST architectural style from other network-based styles is its emphasis on a uniform interface between components.” Roy Fielding
Uniform Interface Uniform resource identification A set of well-defined operations for manipulation A shared set of media-types Hypertext as the engine of application state
Benefits of REST Hypertext is standardized fewer UIs Identification is standardized less communication Exchange protocols are standardized fewer integrations Interactions are standardized fewer semantics Data formats are standardized fewer translations
“ No matter how hard I try, I still think the WS-* stack is bloated, opaque, and insanely complex. I think it is going to be hard to understand, hard to implement, hard to interoperate, and hard to secure.” Tim Bray (XML Co-inventor)
“ If you’re ready for REST I suggest you jump on board right away and get ahead of the curve You’ll have to train your developers in REST principles. You definitely need to provide guidance to your people. What you want to do is work to the point where REST becomes the default for all your distributed applications.” Anne Thomas Manes (Burton Group)
 
Links http://del.icio.us/alan.dean/mvc http://thoughtpad.net/alan-dean Email [email_address] © MMVIII

More Related Content

What's hot (20)

PDF
Intro to html 5
Ian Jasper Mangampo
 
PPT
JSF Custom Components
Michael Fons
 
PPT
What's new and exciting with JSF 2.0
Michael Fons
 
PDF
Apache Wicket Web Framework
Luther Baker
 
PPT
Seam Introduction
ihamo
 
PDF
Web Components for Java Developers
Joonas Lehtinen
 
PPTX
Servlet and jsp interview questions
Sujata Regoti
 
ODP
Devoxx 09 (Belgium)
Roger Kitain
 
PDF
Vaadin Components @ Angular U
Joonas Lehtinen
 
PPTX
The Django Web Application Framework 2
fishwarter
 
PDF
Vaadin Components
Joonas Lehtinen
 
PDF
Introduction to HTML5
Gil Fink
 
PPT
Processing XML with Java
BG Java EE Course
 
PPS
Jsp element
kamal kotecha
 
PDF
Ajax Security
Joe Walker
 
PPTX
MVC Frameworks for building PHP Web Applications
Vforce Infotech
 
PDF
Polymer, A Web Component Polyfill Library
naohito maeda
 
PPT
Boston Computing Review - Java Server Pages
John Brunswick
 
PDF
The Structure of Web Code: A Case For Polymer, November 1, 2014
Tommie Gannert
 
PDF
Portlet Specification 3.0 Is Here!
Dev_Events
 
Intro to html 5
Ian Jasper Mangampo
 
JSF Custom Components
Michael Fons
 
What's new and exciting with JSF 2.0
Michael Fons
 
Apache Wicket Web Framework
Luther Baker
 
Seam Introduction
ihamo
 
Web Components for Java Developers
Joonas Lehtinen
 
Servlet and jsp interview questions
Sujata Regoti
 
Devoxx 09 (Belgium)
Roger Kitain
 
Vaadin Components @ Angular U
Joonas Lehtinen
 
The Django Web Application Framework 2
fishwarter
 
Vaadin Components
Joonas Lehtinen
 
Introduction to HTML5
Gil Fink
 
Processing XML with Java
BG Java EE Course
 
Jsp element
kamal kotecha
 
Ajax Security
Joe Walker
 
MVC Frameworks for building PHP Web Applications
Vforce Infotech
 
Polymer, A Web Component Polyfill Library
naohito maeda
 
Boston Computing Review - Java Server Pages
John Brunswick
 
The Structure of Web Code: A Case For Polymer, November 1, 2014
Tommie Gannert
 
Portlet Specification 3.0 Is Here!
Dev_Events
 

Viewers also liked (12)

PPT
Introduction to ASP.NET MVC
Maarten Balliauw
 
PDF
How To Install ubuntu 12.04 version
VCP Muthukrishna
 
PPTX
Understanding ASP.NET MVC
Shravan Kumar Kasagoni
 
PDF
PhoneGap @ Javascript Directions
Tiang Cheng
 
PPTX
Building a real time html5 app for mobile devices
Tony Abou-Assaleh
 
PPTX
Lezione 1 - Teoria - Accenni sulle reti e sui servizi internet
Giuseppe Cramarossa
 
PPTX
Rapid Prototyping with Cordova aka Phonegap
Josue Bustos
 
PDF
Ionic framework one day training
Troy Miles
 
PDF
Building Mobile Apps with Cordova , AngularJS and Ionic
Kadhem Soltani
 
PDF
Building Mobile Applications with Ionic
Morris Singer
 
PDF
Color your life: how to spice up your life with colors.
Marc Heleven
 
PPTX
Steve Jobs Inspirational Quotes
InsideView
 
Introduction to ASP.NET MVC
Maarten Balliauw
 
How To Install ubuntu 12.04 version
VCP Muthukrishna
 
Understanding ASP.NET MVC
Shravan Kumar Kasagoni
 
PhoneGap @ Javascript Directions
Tiang Cheng
 
Building a real time html5 app for mobile devices
Tony Abou-Assaleh
 
Lezione 1 - Teoria - Accenni sulle reti e sui servizi internet
Giuseppe Cramarossa
 
Rapid Prototyping with Cordova aka Phonegap
Josue Bustos
 
Ionic framework one day training
Troy Miles
 
Building Mobile Apps with Cordova , AngularJS and Ionic
Kadhem Soltani
 
Building Mobile Applications with Ionic
Morris Singer
 
Color your life: how to spice up your life with colors.
Marc Heleven
 
Steve Jobs Inspirational Quotes
InsideView
 
Ad

Similar to Introduction To ASP.NET MVC (20)

PPTX
The Django Web Application Framework 2
fishwarter
 
PPTX
The Django Web Application Framework 2
fishwarter
 
PPTX
The Django Web Application Framework 2
fishwarter
 
PPT
Spring MVC
yuvalb
 
ODP
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
PPT
Ta Javaserverside Eran Toch
Adil Jafri
 
PPT
RESTful SOA - 中科院暑期讲座
Li Yi
 
PPT
Internet Explorer 8 for Developers by Christian Thilmany
Christian Thilmany
 
ODP
Annotation-Based Spring Portlet MVC
John Lewis
 
PPT
Introduction to ASP.NET MVC
Sunpawet Somsin
 
PDF
Intro To Mvc Development In Php
funkatron
 
PDF
Front End Development for Back End Developers - UberConf 2017
Matt Raible
 
PPTX
ASP.NET MVC
Paul Stovell
 
PPTX
Entity framework and how to use it
nspyre_net
 
PDF
Front End Development for Back End Developers - vJUG24 2017
Matt Raible
 
PPT
EPiServer Web Parts
EPiServer Meetup Oslo
 
PPTX
Spring Surf 101
Alfresco Software
 
PPT
Create a web-app with Cgi Appplication
olegmmiller
 
PPTX
SgCodeJam24 Workshop Extract
remko caprio
 
PPT
JSP diana y yo
michael
 
The Django Web Application Framework 2
fishwarter
 
The Django Web Application Framework 2
fishwarter
 
The Django Web Application Framework 2
fishwarter
 
Spring MVC
yuvalb
 
ActiveWeb: Chicago Java User Group Presentation
ipolevoy
 
Ta Javaserverside Eran Toch
Adil Jafri
 
RESTful SOA - 中科院暑期讲座
Li Yi
 
Internet Explorer 8 for Developers by Christian Thilmany
Christian Thilmany
 
Annotation-Based Spring Portlet MVC
John Lewis
 
Introduction to ASP.NET MVC
Sunpawet Somsin
 
Intro To Mvc Development In Php
funkatron
 
Front End Development for Back End Developers - UberConf 2017
Matt Raible
 
ASP.NET MVC
Paul Stovell
 
Entity framework and how to use it
nspyre_net
 
Front End Development for Back End Developers - vJUG24 2017
Matt Raible
 
EPiServer Web Parts
EPiServer Meetup Oslo
 
Spring Surf 101
Alfresco Software
 
Create a web-app with Cgi Appplication
olegmmiller
 
SgCodeJam24 Workshop Extract
remko caprio
 
JSP diana y yo
michael
 
Ad

More from Alan Dean (8)

PDF
Cavity Data
Alan Dean
 
PPTX
Test Driven Development (C#)
Alan Dean
 
PPTX
Test Driven Development (Delphi)
Alan Dean
 
PPTX
Azure, Cloud Computing & Services
Alan Dean
 
PPT
Separating REST Facts from Fallacies
Alan Dean
 
PDF
Future Direction For Agile
Alan Dean
 
PPT
Object Thinking
Alan Dean
 
PPT
Internationalisation And Globalisation
Alan Dean
 
Cavity Data
Alan Dean
 
Test Driven Development (C#)
Alan Dean
 
Test Driven Development (Delphi)
Alan Dean
 
Azure, Cloud Computing & Services
Alan Dean
 
Separating REST Facts from Fallacies
Alan Dean
 
Future Direction For Agile
Alan Dean
 
Object Thinking
Alan Dean
 
Internationalisation And Globalisation
Alan Dean
 

Recently uploaded (20)

DOCX
RECLAIM STOLEN CRYPTO REVIEW WITH RECUVA HACKER SOLUTIONS
camilamichaelj7
 
PDF
David Badaro Explains 5 Steps to Solving Complex Business Issues
David Badaro
 
PDF
Jordan Minnesota City Codes and Ordinances
Forklift Trucks in Minnesota
 
PDF
NewBase 07 July 2025 Energy News issue - 1800 by Khaled Al Awadi_compressed.pdf
Khaled Al Awadi
 
PDF
Flexible Metal Hose & Custom Hose Assemblies
McGill Hose & Coupling Inc
 
PDF
kcb-group-plc-2024-integrated-report-and-financial-statements (3).pdf
DanielNdegwa10
 
PDF
SUMMER SAFETY FLYER SPECIAL Q3 - 16 Pages
One Source Industrial Supplies
 
PDF
Rostyslav Chayka: Управління командою за допомогою AI (UA)
Lviv Startup Club
 
PDF
15 Essential Cloud Podcasts Every Tech Professional Should Know in 2025
Amnic
 
PDF
Kirill Klip GEM Royalty TNR Gold Presentation
Kirill Klip
 
PDF
Buy Boys Long Sleeve T-shirts at Port 213
Port 213
 
PDF
Azumah Resources reaffirms commitment to Ghana amid dispute with Engineers & ...
Kweku Zurek
 
PDF
LEWIONICS SCO Company Profile UAE JULY 2025
Natalie Lewes
 
PDF
Top Farewell Gifts for Seniors Under.pdf
ThreadVibe Living
 
PPTX
Hackathon - Technology - Idea Submission Template -HackerEarth.pptx
nanster236
 
PDF
Securiport - A Global Leader
Securiport
 
PDF
Blind Spots in Business: Unearthing Hidden Challenges in Today's Organizations
Crimson Business Consulting
 
PPTX
epi editorial commitee meeting presentation
MIPLM
 
DOCX
How to Choose the Best Dildo for Men A Complete Buying Guide.docx
Glas Toy
 
PDF
CBV - GST Collection Report V16. pdf.
writer28
 
RECLAIM STOLEN CRYPTO REVIEW WITH RECUVA HACKER SOLUTIONS
camilamichaelj7
 
David Badaro Explains 5 Steps to Solving Complex Business Issues
David Badaro
 
Jordan Minnesota City Codes and Ordinances
Forklift Trucks in Minnesota
 
NewBase 07 July 2025 Energy News issue - 1800 by Khaled Al Awadi_compressed.pdf
Khaled Al Awadi
 
Flexible Metal Hose & Custom Hose Assemblies
McGill Hose & Coupling Inc
 
kcb-group-plc-2024-integrated-report-and-financial-statements (3).pdf
DanielNdegwa10
 
SUMMER SAFETY FLYER SPECIAL Q3 - 16 Pages
One Source Industrial Supplies
 
Rostyslav Chayka: Управління командою за допомогою AI (UA)
Lviv Startup Club
 
15 Essential Cloud Podcasts Every Tech Professional Should Know in 2025
Amnic
 
Kirill Klip GEM Royalty TNR Gold Presentation
Kirill Klip
 
Buy Boys Long Sleeve T-shirts at Port 213
Port 213
 
Azumah Resources reaffirms commitment to Ghana amid dispute with Engineers & ...
Kweku Zurek
 
LEWIONICS SCO Company Profile UAE JULY 2025
Natalie Lewes
 
Top Farewell Gifts for Seniors Under.pdf
ThreadVibe Living
 
Hackathon - Technology - Idea Submission Template -HackerEarth.pptx
nanster236
 
Securiport - A Global Leader
Securiport
 
Blind Spots in Business: Unearthing Hidden Challenges in Today's Organizations
Crimson Business Consulting
 
epi editorial commitee meeting presentation
MIPLM
 
How to Choose the Best Dildo for Men A Complete Buying Guide.docx
Glas Toy
 
CBV - GST Collection Report V16. pdf.
writer28
 

Introduction To ASP.NET MVC

  • 1. Introducing ASP.NET MVC Alan Dean, Senior Technologist
  • 2. Model-View-Controller (MVC) is a well-known design pattern The original 1978 implementation is described in depth in the influential 1992 paper “ Applications Programming in Smalltalk-80: How to use Model-View-Controller (MVC)” by Steve Burbeck
  • 3. …“ the concept of the design pattern in software provides a key to helping developers leverage the expertise of other skilled architects.” Grady Booch, 1995
  • 4.  
  • 5. MVC consists of three kinds of objects The Model is the application object The View is the screen presentation The Controller defines the way the user interface reacts to user input
  • 6. Before MVC, user interface designs tended to lump these objects together MVC decouples them to increase flexibility and reuse
  • 8. In his paper Steve Burbeck describes two variations of MVC a passive model and an active model
  • 9. The passive model is employed when one controller manipulates the model exclusively The controller modifies the model and then informs the view that the model has changed and should be refreshed The model in this scenario is completely independent of the view and the controller, which means that there is no means for the model to report changes in its state
  • 10. Controller View Model handleEvent service update getData
  • 11. The HTTP protocol is an example of this. The browser displays the view and responds to user input, but it does not detect changes in the data on the server. Only when the browser explicitly requests a refresh is the server interrogated for changes.
  • 12. Separation of Concerns (SoC) Object types become ‘pluggable’ Intra-team dependency is reduced Testability is enhanced Application flow can be hard to grok
  • 13. MVC Web Frameworks Java has Swing , Struts , Grails and others Perl has Catalyst , Gantry , Jifty and others PHP has Zend , Zoop , Agavi and others Python has Django , Gluon , Pylon and others Ruby on Rails is famously ‘opinionated’ … and .NET?
  • 14. .NET MVC Web Frameworks Spring.NET http://www.springframework.net/ Maverick.NET http://mavnet.sourceforge.net/ MonoRail http://www.castleproject.org/monorail/ … and now ASP.NET MVC from Microsoft http://asp.net/downloads/3.5-extensions/
  • 15. “ The ASP.NET MVC framework is a lightweight, highly testable presentation framework that is integrated with existing ASP.NET features, such as master pages and membership-based authentication. The MVC framework is defined in the System.Web.Mvc namespace and is a fundamental, supported part of the System.Web namespace”
  • 16. Demo Create a new ASP.NET MVC Solution
  • 17. HTTP Request Flow HTTP Response GET /Home/Index HTTP/1.1 HTTP Request Route Handler Controller Model View
  • 18. HTTP Request Flow public class Global : HttpApplication { protected void Application_Start( object sender, EventArgs e) { RouteTable .Routes.Add( new Route { Url = &quot;[controller]/[action]/[id]&quot; , Defaults = new { action = &quot;Index&quot; , id = ( string ) null }, RouteHandler = typeof ( MvcRouteHandler ) }); } } HTTP Response Route Handler HTTP Request Controller Model View
  • 19. HTTP Request Flow public class HomeController : Controller { [ ControllerAction ] public void Index() { CompanyInfo companyInfo = new CompanyInfo (); companyInfo.CompanyName = &quot;Your company name here&quot; ; RenderView( &quot;Index&quot; , companyInfo); } } HTTP Response Controller HTTP Request Route Handler Model View
  • 20. HTTP Request Flow public class CompanyInfo { public string CompanyName { get ; set ; } } HTTP Response Model HTTP Request Route Handler Controller View
  • 21. HTTP Request Flow public partial class Index : ViewPage < CompanyInfo > { } Response View <% @ Page Language =&quot;C#&quot; AutoEventWireup =&quot;true&quot; CodeBehind =&quot;Index.aspx.cs&quot; Inherits =&quot;MvcApplication.Views.Home.Index&quot; %> < html > < head > < title > <%= this.ViewData.companyName %> </ title > </ head > < body > <%= Html.ActionLink( “Homepage&quot; , &quot;Index&quot; , &quot;Home&quot; ) %> < div > Welcome! </ div > </ body > </ html > HTTP Request Route Handler Controller Model
  • 22. HTTP Request Flow HTTP/1.1 200 OK Content-Type: text/html <html> <head> <title>Your company name here</title> </head> <body> <a href=&quot;/Home/Index&quot;>Index</a> <div>Welcome!</div> </body> </html> HTTP Request Route Handler Controller Model View HTTP Response
  • 23. Wiki A wiki is software that allows users to create, edit, and link web pages easily
  • 24. Ward Cunningham, developer of the first wiki, WikiWikiWeb , originally described it as &quot;the simplest online database that could possibly work&quot;
  • 25. Wiki Database CREATE TABLE [dbo].[PageTable] ( [Id] int IDENTITY (1,1) NOT NULL , [Guid] uniqueidentifier NOT NULL , [LastModified] datetime NOT NULL , [Removed] datetime NULL , [Title] varchar (255) NOT NULL , [Body] ntext NOT NULL );
  • 26. Wiki HTTP API GET / GET /page.html POST /page GET /page/[title] GET /page/[title].txt GET /page/[title].html GET /page/[title].atom PUT /page/[title] DELETE /page/[title]
  • 27. GET The GET method means retrieve whatever information (in the form of an entity) is identified by the Request-URI. Safe & Idempotent
  • 28. GET / Accept: text/html, */* 303 See Other Location: http://localhost/page.html Cache-Control: public Expires: Thu, 31 Jan 2008 16:00:00 GMT
  • 29. GET /page.html Accept: text/html, */* 200 OK Content-Type: text/html Cache-Control: public Expires: Thu, 31 Jan 2008 16:00:00 GMT <html> <head><title>…</title></head> <body> <form action=&quot; /page &quot; method=&quot; post &quot; enctype=&quot; application/x-www-form-urlencoded &quot;> <input type=&quot;text&quot; name=&quot;title&quot; maxlength=&quot;255&quot; /> <textarea name=&quot;body&quot; rows=&quot;25&quot; cols=&quot;80&quot;></textarea> <input type=&quot;submit&quot; value=&quot;Create Page&quot; /> </form> </body> </html>
  • 30. POST The POST method is used to request that the origin server accept the entity enclosed in the request as a new subordinate of the resource identified by the Request-URI
  • 31. POST /page Content-Type: application/x-www-form-urlencoded title=Welcome&body=Welcome+to+my+new+wiki. 201 Created Content-Type: text/html Content-Location: http://localhost/page/Welcome Cache-Control: no-cache <html> <head> <title>…</title> <meta http-equiv=&quot; refresh &quot; content=&quot;0;url= http://localhost:64701/page/Welcome &quot;> </head> <body>…</body> </html>
  • 32. GET /page/Welcome Accept: text/html, */* 303 See Other Location: http://localhost/page/Welcome.html Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT Vary: Accept
  • 33. GET /page/Welcome.html Accept: text/html, */* 200 OK Content-Type: text/html Content-Location: http://localhost/page/Welcome Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT <html> <head> <title>…</title> <link href=&quot; http://localhost/page/Welcome.atom &quot; rel=&quot; alternate &quot; title=&quot;…&quot; type=&quot; application/atom+xml &quot; /> </head> <body>…</body> </html>
  • 34. GET /page/Welcome.atom Accept: application/atom+xml 200 OK Content-Type: application/atom+xml Content-Location: http://localhost/page/Welcome Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT <?xml version=&quot;1.0&quot; encoding=&quot;utf-8”?> <feed xml:lang=&quot;en&quot; xmlns=&quot;http://www.w3.org/2005/Atom&quot;> … <link href=&quot; http://localhost:64701/page/Welcome &quot; rel=&quot; source &quot; /> <link href=&quot; http://localhost:64701/page/Welcome.atom &quot; rel=&quot; self &quot; type=&quot;application/atom+xml&quot; hreflang=&quot;en&quot; title=&quot;…&quot; /> <link href=&quot; http://localhost:64701/page/Welcome.html &quot; rel=&quot; alternate &quot; type=&quot;text/html&quot; hreflang=&quot;en&quot; title=&quot;…&quot; /> <link href=&quot; http://localhost:64701/page/Welcome.txt &quot; rel=&quot; alternate &quot; type=&quot;text/plain&quot; hreflang=&quot;en&quot; title=&quot;…&quot; /> <entry>…</entry> </feed>
  • 35. GET /page/Welcome Accept: text/plain 303 See Other Location: http://localhost/page/Welcome.txt Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT Vary: Accept GET /page/Welcome.txt Accept: text/plain 200 OK Content-Type: text/plain Content-Location: http://localhost/page/Welcome Cache-Control: public Last-Modified: Tue, 29 Jan 2008 16:00:00 GMT Welcome to my new wiki.
  • 36. PUT The PUT method requests that the enclosed entity be stored under the supplied Request-URI. If the Request-URI refers to an already existing resource, the enclosed entity SHOULD be considered as a modified version of the one residing on the origin server. Idempotent
  • 37. PUT /page/Welcome Content-Type: text/plain Welcome to my new [[wiki]]. 204 No Content Cache-Control: no-cache
  • 38. DELETE The DELETE method requests that the origin server delete the resource identified by the Request-URI. Idempotent
  • 39. DELETE /page/Welcome 204 No Content Cache-Control: no-cache
  • 40.  
  • 41. RE presentational S tate T ransfer
  • 42. REST: The Web Used Correctly A system or application architecture … that uses HTTP, URI and other Web standards “correctly” … is “on” the Web, not tunnelled through it
  • 43. REST is an Architectural Style Defines a set of key “constraints” … that, if met, make an architecture “RESTful” … with the Web as one example
  • 44. Equate “REST” with “RESTful HTTP usage” Stefan Tilkov
  • 45. Deriving REST Client-Server Stateless Cache Uniform interface Layered system Code on Demand
  • 46. “ The central feature that distinguishes the REST architectural style from other network-based styles is its emphasis on a uniform interface between components.” Roy Fielding
  • 47. Uniform Interface Uniform resource identification A set of well-defined operations for manipulation A shared set of media-types Hypertext as the engine of application state
  • 48. Benefits of REST Hypertext is standardized fewer UIs Identification is standardized less communication Exchange protocols are standardized fewer integrations Interactions are standardized fewer semantics Data formats are standardized fewer translations
  • 49. “ No matter how hard I try, I still think the WS-* stack is bloated, opaque, and insanely complex. I think it is going to be hard to understand, hard to implement, hard to interoperate, and hard to secure.” Tim Bray (XML Co-inventor)
  • 50. “ If you’re ready for REST I suggest you jump on board right away and get ahead of the curve You’ll have to train your developers in REST principles. You definitely need to provide guidance to your people. What you want to do is work to the point where REST becomes the default for all your distributed applications.” Anne Thomas Manes (Burton Group)
  • 51.