4. Whatis ASP.NET MVC? Framework ASP.NET MVC Framework, built on top of ASP.NET core framework implements the “Model, View and Controller” pattern 20.10.2010 Folie 4
5. Whatis ASP.NET MVC? MVC Power Complete control on HTML. Smooth Web 2.0 Development . SEO-friendly URLs. Easy Test Driven Development (TDD). Stateless Previous ASP.NET technology based on “ViewState” Caused a lot of unnecessary traffic and complexity 20.10.2010 Folie 5
6. Whatis ASP.NET MVC? 20.10.2010 Folie 6 Model Encapsulates application’s Data and related Logics Holds the Data Objects Other term: “business layer” Should be “fat” has usually several more layers (later topic) View Handles application’s data presentation Where all the HTML / CSS / JS / … stuff can be found Controller Manages application’s Flow and Navigational logics Should be “Skinny” as few as possible code
7. Whatis ASP.NET MVC? 20.10.2010 Folie 7 <<<<< Always Remember! Skinny Controller,Fat Model
8. Whatis ASP.NET MVC? MVC + Routing Model View Controller Router URL Mapping “Loads” for the right controller Calls the right method of the controller Or sends a HTTP 404 error message on no match 20.10.2010 Folie 8
9. 02 One HTTP Request in Detail 20.10.2010 Folie 9
10. One HTTP Request in Detail 20.10.2010 Folie 10 0a) Browser (eg Firefox) opens a TCP connection to the Webserver (Microsoft IIS) on Port 80, sends the following text (text extremely shortened) GET / HTTP/1.1 Host: yoursite.com IIS decides which application to call(simplified. in real a lot of more stuff is done here) 1) Request arrives at the MVC Application
11. One HTTP Request in Detail 20.10.2010 Folie 11 2) Based upon the Routing table configuration, the URL request is mapped to an Action (method) inside an appropriate Controller
12. One HTTP Request in Detail 20.10.2010 Folie 12 3) Controller accesses the Model to process the data with applying business logics
13. One HTTP Request in Detail 20.10.2010 Folie 13 4) Model accesses database and results are returned back to the controller’s Action
14. One HTTP Request in Detail 20.10.2010 Folie 14 5) Action populates the view with processed data and the View renders the User Interface (HTML)
15. One HTTP Request in Detail 20.10.2010 Folie 15 IIS sends an HTTP Responseback to the waiting browser: HTTP/1.1 200 OK Server: Microsoft-IIS/6.0 Content-Type: text/html Content-Length: 999 <html><body>…</body></html>