Chapter 4. Action-packed controllers
This chapter covers
In the last couple of chapters, we’ve looked at the basics of creating a simple Guest-book application and at different options available for passing data to views. In this chapter, we’ll finish off the Guestbook example by looking at controllers in a bit more detail. We’ll explore what should (and shouldn’t) be part of a controller and look at how to manually construct view models, validate simple user input, and write controller actions that don’t use a view. This will give us a good set of building blocks for constructing the most common types of controller actions.
We’ll also briefly introduce you to unit testing controller actions so you can verify that they’re working correctly. We’ll start off by looking at the default unit test project and then move on to creating unit tests for the GuestbookController that we’ve been working with in previous chapters.