10
ASP.NET MVC Architecture

02 architecture

Embed Size (px)

Citation preview

Page 1: 02 architecture

ASP.NET MVC Architecture

Page 2: 02 architecture

Hands-on ASP.NET MVC

Page 3: 02 architecture

The project layout

Page 4: 02 architecture

How it works � Models

� They say this is where the business logic goes and DB access.

� Properly put elsewhere. More on that later.

� Views � The visual portion � When done right, you have ONLY what is required to

create the visual part of the HTML. � Code smell: when anything else is in there.

� Controllers � Where the action happens! Glue that ties everything

together.

Page 5: 02 architecture

How MVC works Br

ow

ser

Co

ntr

olle

r

Mo

de

l

Vie

w

Page 6: 02 architecture

Typical steps 1.  The user interacts with the user interface in some way. 2.  The controller handles the input and converts the

event into user action, understandable for the model. 3.  The controller notifies the model of the user action,

possibly resulting in a change in the model's state. 4.  A view queries the model in order to generate an

appropriate user interface. 5.  The view gets its own data from the model 6.  The user interface waits for further user interactions,

which restarts the cycle.

Page 7: 02 architecture

Doing their jobs �  Model

�  Models the data without any concern for how it is to be displayed

�  View �  Displays the data without any concern for how

it is generated or manipulated �  Controller

�  Be the go-between so that both the View and the Model can concentrate on doing their parts exclusively well

�  May translate the data from the model so it can be displayed in the view

�  May read data from the view and process it into something the model can read

Page 8: 02 architecture

Remaining folders � Shared

�  Partial views

� Scripts �  JavaScript �  jQuery

� Content �  CSS �  Images

� App_Data �  Database �  XML files

Page 9: 02 architecture

Conclusion � ASP.NET MVC is another way to create dynamic

web sites �  It allows for much better design practices than

ASP.NET WebForms but it is more complex

Page 10: 02 architecture

Further study