24
STAATLICH ANERKANNTE FACHHOCHSCHULE Author: Dip.-Inf. (FH) Johannes Hoppe Datum: 06.10.2010 Thanks to: Eng. Khaled Musaied STUDIEREN UND DURCHSTARTEN.

Ria 03 - Hello ASP.NET MVC

Embed Size (px)

DESCRIPTION

 

Citation preview

Page 1: Ria 03 - Hello ASP.NET MVC

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

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

What is ASP.NET MVC?

0110.04.2023

Folie 3

Page 4: Ria 03 - Hello ASP.NET MVC

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

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

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

What is ASP.NET MVC?

10.04.2023

Folie 7

<<<<<

Always Remember!

Skinny Controller,

Fat Model

Page 8: Ria 03 - Hello ASP.NET MVC

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

One HTTP Request in Detail

0210.04.2023

Folie 9

Page 10: Ria 03 - Hello ASP.NET MVC

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

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

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

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

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

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

One HTTP Request in Detail

10.04.2023

Folie 16

Page 17: Ria 03 - Hello ASP.NET MVC

Code Examples

0310.04.2023

Folie 17

Page 18: Ria 03 - Hello ASP.NET MVC

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

Code Examples – Controller

10.04.2023

Folie 19

Page 20: Ria 03 - Hello ASP.NET MVC

Code Examples – View (ASP.NET MVC v1)

10.04.2023

Folie 20

Page 21: Ria 03 - Hello ASP.NET MVC

Code Examples – View output (MVC)

10.04.2023

Folie 21

Page 22: Ria 03 - Hello ASP.NET MVC

Code Examples – Routes

10.04.2023

Folie 22

URL:http://yoursite.com/Customers/Details/21

Page 23: Ria 03 - Hello ASP.NET MVC

Rich Internet Applications

Questions?

?

10.04.2023

Folie 23

Page 24: Ria 03 - Hello ASP.NET MVC

THANK YOUFOR YOUR ATTENTION

10.04.2023

Folie 24