- A Story with a Moral
- What Is Good Software?
- What Is ASP.NET MVC?
- The Architecture of an ASP.NET MVC Application
- Understanding the Sample ASP.NET MVC Application
- Summary
The Architecture of an ASP.NET MVC Application
An MVC application, a Model View Controller application, is divided into the following three parts:
- Model—An MVC model contains all of an application's logic that is not contained in a view or controller. The model includes all of an application's validation logic, business logic, and data access logic. The MVC model contains model classes that model objects in the application's domain.
- View—An MVC view contains HTML markup and view logic.
- Controller—An MVC controller contains control-flow logic. An MVC controller interacts with MVC models and views to control the flow of application execution.
Enforcing this separation of concerns among models, views, and controllers has proven to be a useful way of structuring a web application.
First, sharply separating views from the remainder of a web application enables you to redesign the appearance of your application without touching any of the core logic. A web page designer (the person who wears the black beret) can modify the views independently of the software engineers who build the business and data access logic. People with different skills and roles can modify different parts of the application without stepping on each other's toes.
Furthermore, separating the views from the remainder of your application logic enables you to easily change the view technology in the future. One fine day, you might decide to re-implement the views in your application using Silverlight instead of HTML. If you entangle your view logic with the rest of your application logic, migrating to a new view technology will be difficult.
Separating controller logic from the remainder of your application logic has also proven to be a useful pattern for building web applications. You often need to modify the way that a user interacts with your application. You don't want to touch your view logic or model logic when modifying the flow of execution of your application.