50 likes | 237 Views
ASP.NET MVC. The Basic Big Picture Juhani Välimäki 12.2.2013. Web Server. Browser / Client. Global.asax. Request protocol , e.g . http:// Server name , e.g . myy.haaga-helia.fi Port, e.g . 8080 More URI, e.g . Controller /Home , Action /Index Possible parameters Verb :
E N D
ASP.NET MVC The Basic Big Picture Juhani Välimäki 12.2.2013
Web Server Browser / Client Global.asax • Request • protocol, e.g. http:// • Server name, e.g. myy.haaga-helia.fi • Port, e.g. 8080 • More URI, e.g. Controller /Home, Action /Index • Possibleparameters • Verb: • GET|POST URI mapper Controller’sactionsfetchorcreate the Model, possiblyupdating it. Controller Action Controller passes the (possiblymodified) Model to anydesiredView Model URI link Data XHTML pages with form and input elements. And links View • Response • XHTML page with links for sendingrequestsback to Web server • Possible XHTML formelement with input fields and submitelements • Referenced .css/.jpg/.js etc. files _Layout.cshtml The Viewparses data from the Modelto the elements of the View (page) and adds Action links to the page forthe nextround of Request-Resp Index.cshtml
Browser / Client Web Server • Global.asaxconfig file: • defaultcontrollers, actions & parameters • ways to parseprovidedcontroller, action and/orparameterinformation Global.asax URI mapper • URI mapping • whichcontroller? • which action? • whichparameterized version of the action? • Anyincoming URI canbemapped to anyinternal URI! All, including the Controller, Action and Parameters, is customizable! Controller Action Model URI link Data XHTML pages with form and input elements. And links View _Layout.cshtml Index.cshtml
Modelcouldbe, e.g.: • Single DTO object • Collection of DTO objects • Complicatedobjectreferencestructure • (Interfaceclassorobject for database, evensomeBusiness LogicLayeror DAO object) • Proxy object for socalled ORM Web Server Browser / Client Global.asax URI mapper • Model is passivefrom MVC point of view • Controller createsorfetches the Modele.g. from DB/ORM/EDM • Also the Viewwillbegivenaccess to the Model • (=”Also the View is in controlof/knows the Model”) • Modeldoesn’tknow the Control nor the View • YetModelcanruncodeifasked to Controller Action Model URI link XHTML pages with form and input elements. And links Data View _Layout.cshtml Index.cshtml
Web Server Browser / Client Global.asax URI mapper Controller Action Model URI link Data XHTML pages with form and input elements. And links View • View is formed: • From the ”masterpage” part/Views/Shared/_Layout.cshtml • Viewpartwillbeadded inside. E.g. /Views/Home/Index.cshtml is the HomeController’s Index action’sviewcontent • Possible_Partialviews(underscore) • Use Visual Studio to auto-createanyfoldersorfilessothatlinkageswork _Layout.cshtml Index.cshtml