The MVC Pattern

Wikipedia attributes the Model-View-Controller architectural pattern to Trygve Mikkjel Heyerdahl Reenskaug, who developed it in 1979 while working on Smalltalk at Xerox PARC.

Possible n-tier architecture

Figure 8-2. Possible n-tier architecture

The key concept in this pattern is that you start with a model—that is, a representation of the problem domain. The model includes the state of the application and its data; it focuses on the structure of the data and how it will be manipulated.

The second key concept in the MVC pattern is the view, which is how the model is presented to the user (i.e., the user interface). The view typically includes controls with which the user interacts (drop-down lists, buttons, etc.).

The third and final key concept is (you guessed it!) the controller, which responds to user actions (and other events) and mediates the interaction between the model and the view, possibly modifying one and/or the other. For example, pressing a button may cause the controller to send a message to the model, thereby changing the state of the model. This may in turn cause the controller to send another message, this time back to the view, updating the view to represent the new state of the model.

The ASP.NET MVC Framework

As stated earlier in this chapter, in most of .NET (including some of .NET 3.5), MVC is not easily implemented, as the controller's responsibilities are spread out among the ...

Get Programming .NET 3.5 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.