CHAPTER 22

image

Controllers and Actions

In this chapter, I continue describing the Web API dispatch process and focus on controllers and action methods. I explain how controllers work in Web API and describe the dispatch process implemented by the default controller class, ApiController. Along the way, I show you how to resolve a common routing problem, explain how requests are mapped to action methods in RESTful Web API controllers, and show you how to customize request dispatching. Table 22-1 summarizes this chapter.

Table 22-1. Chapter Summary

Problem

Solution

Listing

Create a controller.

Define a class that implements the IHttpController interface ...

Get Expert ASP.NET Web API 2 for MVC Developers 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.