Ria 03 - Hello ASP.NET MVC
-
Upload
johannes-hoppe -
Category
Technology
-
view
1.814 -
download
0
description
Transcript of Ria 03 - Hello ASP.NET MVC
![Page 1: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/1.jpg)
STAATLICHANERKANNTEFACHHOCHSCHULE
Author: Dip.-Inf. (FH) Johannes HoppeDatum: 06.10.2010
Thanks to: Eng. Khaled Musaied
STUDIERENUND DURCHSTARTEN.
![Page 2: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/2.jpg)
STAATLICHANERKANNTEFACHHOCHSCHULE
RIA – Rich Internet Applications
Author: Dip.-Inf. (FH) Johannes HoppeDatum: 06.10.2010
Thanks to: Eng. Khaled Musaied
![Page 3: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/3.jpg)
What is ASP.NET MVC?
0110.04.2023
Folie 3
![Page 4: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/4.jpg)
What is ASP.NET MVC?
Framework
› ASP.NET MVC Framework, built on top of ASP.NET core framework› implements the “Model, View and Controller” pattern
10.04.2023
Folie 4
![Page 5: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/5.jpg)
What is 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
10.04.2023
Folie 5
![Page 6: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/6.jpg)
What is ASP.NET MVC?
10.04.2023
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
![Page 7: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/7.jpg)
What is ASP.NET MVC?
10.04.2023
Folie 7
<<<<<
Always Remember!
Skinny Controller,
Fat Model
![Page 8: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/8.jpg)
What is 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
10.04.2023
Folie 8
![Page 9: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/9.jpg)
One HTTP Request in Detail
0210.04.2023
Folie 9
![Page 10: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/10.jpg)
One HTTP Request in Detail
10.04.2023
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.1Host: 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
![Page 11: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/11.jpg)
One HTTP Request in Detail
10.04.2023
Folie 11
› 2) Based upon the Routing table configuration, the URL request is mapped to an Action (method) inside an appropriate Controller
![Page 12: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/12.jpg)
One HTTP Request in Detail
10.04.2023
Folie 12
› 3) Controller accesses the Model to process the data with applying business logics
![Page 13: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/13.jpg)
One HTTP Request in Detail
10.04.2023
Folie 13
› 4) Model accesses database and results are returned back to the controller’s Action
![Page 14: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/14.jpg)
One HTTP Request in Detail
10.04.2023
Folie 14
› 5) Action populates the view with processed data and the View renders the User Interface (HTML)
![Page 15: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/15.jpg)
One HTTP Request in Detail
10.04.2023
Folie 15
› IIS sends an HTTP Responseback to the waiting browser:
HTTP/1.1 200 OKServer: Microsoft-IIS/6.0Content-Type: text/htmlContent-Length: 999
<html><body>…</body></html>
![Page 16: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/16.jpg)
One HTTP Request in Detail
10.04.2023
Folie 16
![Page 17: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/17.jpg)
Code Examples
0310.04.2023
Folie 17
![Page 18: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/18.jpg)
Code Examples – Model
10.04.2023
Folie 18
Note: this only a Data Object, whiteout any business logic!
![Page 19: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/19.jpg)
Code Examples – Controller
10.04.2023
Folie 19
![Page 20: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/20.jpg)
Code Examples – View (ASP.NET MVC v1)
10.04.2023
Folie 20
![Page 21: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/21.jpg)
Code Examples – View output (MVC)
10.04.2023
Folie 21
![Page 22: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/22.jpg)
Code Examples – Routes
10.04.2023
Folie 22
URL:http://yoursite.com/Customers/Details/21
![Page 23: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/23.jpg)
Rich Internet Applications
Questions?
?
10.04.2023
Folie 23
![Page 24: Ria 03 - Hello ASP.NET MVC](https://reader033.fdocuments.us/reader033/viewer/2022061209/548c4043b47959190d8b62ae/html5/thumbnails/24.jpg)
THANK YOUFOR YOUR ATTENTION
10.04.2023
Folie 24