liveBook · Manning

MapControllers

As explained in ASP.NET Core in Action, 3e

MapControllers is an ASP.NET Core endpoint-mapping method that exposes attribute-routed controller actions as endpoints.

MapControllers exposes attribute-routed web API controller actions as endpoints. It lets routing match incoming URLs to action methods, while each action can receive requests and return an HTTP response. section 20.1

Mapping a simple API controller

A web API template registers controllers with AddControllers(), then calls app.MapControllers(). A FruitController action marked [HttpGet("fruit")] responds to GET /fruit, returning its string collection as JSON.

How ASP.NET Core in Action, 3e covers it

How deep it goes
Explains endpoint registration and request matching, but does not descend into routing internals.
Examples
Uses Program.cs, FruitController, GET /fruit, JSON serialization, and an attribute-routed fruit lookup.
What it assumes
Assumes basic ASP.NET Core project setup and controller knowledge while showing the required AddControllers registration.
What you can do after
Configure an ASP.NET Core web API so attribute-routed controller actions receive HTTP requests.
How it connects
Connects attribute routing with controller actions, AddControllers, endpoint routing, and conventional routing.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of ASP.NET Core in Action, 3e. The section links point to the parts of the book it draws on.