O'Reilly logo

Beginning ASP.NET MVC 1.0 by Keyvan Nayyeri, Simone Chiaretta

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Chapter 5. The Controller

The controller is the last letter of MVC, but if the naming followed the real correlation between the components of the pattern, it would have been placed in the middle. The controller is the orchestrator of the operations and is the component that stands between the model and view and passes data between the two.

The previous chapter covered the model part of the pattern. In this chapter, you learn in detail about the controller.

Specifically, you learn:

  • The responsibilities of the controller

  • How to create the controller

  • How to read inputs and pass data to the view

  • How to access the core ASP.NET objects, like Response, Cache, and similar objects

What the Controller Does

You already had a quick overview of how the controller fits into the MVC pattern in Chapter 1. In this section, you learn in detail what its responsibilities are.

The controller is the main component of an MVC application, and its role is even more important here in the ASP.NET MVC framework, which adopts the Passive View pattern. One common misconception is that the main role of the controller is to keep the model and the view separated, but its main role is to mediate between the end user and the application: The fact that it also connects the model with the view is just a side effect. In fact, not including the routing mechanism, the controller is the first component of the application that receives the input from the users.

The tasks that the controller has to perform are capturing and validating ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required