Chapter 3. The controller in depth

 

This chapter covers

  • Understanding controller anatomy
  • Leveraging viewless controllers
  • Testing controllers
  • Using form and querystring values
  • Binding action parameter
  • Developing action filters

The focus of the Model-View-Controller pattern is the controller. With this pattern, every request is handled by a controller and rendered by a view. Without the controller, presentation and business logic would move to the view, as we have seen with Web Forms. With the ASP.NET MVC Framework, every request routes to a controller, which is simply a class that implements the IController interface. Microsoft provides the base class System.Web.Mvc.Controller to make creating a controller easy. The controller base class you choose is not crucial because most request processing goes into executing the ActionResult, which is the type that each action returns.

3.1. The controller action

3.2. Simple controllers do not need a view

3.3. Testing controllers

3.4. Simple actions and views

3.5. Working with form values

3.6. Processing querystring parameters

3.7. Binding more complex objects in action parameters

3.8. Options for passing ViewData

3.9. Filters

3.10. Summary

sitemap