Chapter 12. Lightweight controllers
This chapter covers
In the previous chapter, we looked at using AutoMapper to carry some of the burden of the repetitive, manual labor associated with mapping view models. In this chapter, we’ll continue to investigate unburdening our controllers with simple refactoring and application architecture.
Do you remember those swollen and unwieldy Page_Load methods in Web Forms? Those methods can quickly grow out of control and stage a revolt against your codebase. Controller actions are dangerous too. Nestled snugly between the model and view, controllers are an easy place to put decision-making code, and they’re often mistaken for a good place to put that logic. And it’s quite convenient, at first. It just takes two lines of code to build a select list in an action method. And adding a filter attribute to the controller is a simple way to manage global data for a master page.