0% found this document useful (0 votes)
30 views

Model View Controller

The document discusses the core concepts of Model View Controller (MVC) including the model, view, and controller. It describes advantages like separation of concerns and better support for test-driven development. It also covers action results, partial views, routing, and how the MVC framework works by routing requests to controllers, retrieving data from models, and returning views populated with data.

Uploaded by

Ajith Kumar Rs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
30 views

Model View Controller

The document discusses the core concepts of Model View Controller (MVC) including the model, view, and controller. It describes advantages like separation of concerns and better support for test-driven development. It also covers action results, partial views, routing, and how the MVC framework works by routing requests to controllers, retrieving data from models, and returning views populated with data.

Uploaded by

Ajith Kumar Rs
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 11

MVC

Model View Controller


Model View Controller

Model
Classes that represent the data of the application and that use validation
logic to enforce business rules for that data.

View
Template files that your application uses to dynamically generate HTML
responses.

Controller
Classes that handle incoming browser requests, retrieve model data, and
then specify view templates that return a response to the browser.


Advantages
Separation of Concerns
Better Support For Test Driven Development
Clean URL
Better For Search Engine Optimization
Full Control Over the User Interface or the HTML
Loosely Coupled so Each Component can be tested
independently.

Action Results
Represents the result of an action method.
Controller action response to a browser request
Different Action Result types
1. ViewResult
2. EmptyResult
3. ContentResult
4. JsonResult
5. JavaScriptResult .., etc
http://msdn.microsoft.com/en-
us/library/system.web.mvc.actionresult%28v=vs.118%29.aspx



PARTIAL VIEW

A partial view enables you to define a view that will be
rendered inside a parent view.

Partial views are implemented as ASP.NET user controls (.ascx).

We can render a view inside a parental view and to create
reusable content in the project.


MVC Routing
Responsible for mapping incoming browser requests to
particular MVC controller actions

ASP.NET Routing is setup in two places.
1. Web.config
2. Global.asax

MVC Routing overview
/Home/Index/3
The Default route maps this URL to the following parameters:
controller = Home
action = Index
id = 3

When you request the URL /Home/Index/3, the following
code is executed:
HomeController.Index(3)



How ASP.NET MVC works

How ASP.NET MVC works

1) User makes the request for some resource in server (by putting some URL
in the browser).
2) Request comes to controller first
3) Controller if required talk to model for data.
4) Model operates on database (or on some other data sources) and return
data (in form of business objects) to controller.
5) Controller chooses the appropriate view (like say Customer view which
will may contain some html tables, drop downs, textboxes).
6) Controller passes the data (model data retrieved in step 4) to chosen
view(in step 5), where data will be populated as per convenience.
7) Controller sends back view to the user.

THANK YOU

You might also like