liveBook · Manning

ApiController

ApiController is an ASP.NET Core attribute that enables API-specific conventions and behavior for controller classes, including request binding and validation handling.

How 2 Manning books explain it

ASP.NET Core in Action, 3e

ApiController is an ASP.NET Core attribute that enables conventions for web API controllers, including attribute routing, automatic validation responses, binding-source inference, and Problem Details responses.

How it is used
Applies common web API controller conventions to reduce repeated request-binding and error-handling code.
How deep it goes
Explains conventions through before-and-after controller actions and shows how to disable one; it does not detail their internal implementation.
Examples
Uses a POST update action with a required model property, an invalid-request response, and an explicit `NotFound()` result.
What you can do after
Apply it via `[ApiController]` to simplify a web API controller, then configure a convention when necessary.

Read how ASP.NET Core in Action, 3e explains ApiController →

Building Web APIs with ASP.NET Core

The ApiController attribute is an ASP.NET Core attribute that enables API-controller conventions, including automatic handling of model-binding and validation failures.

How it is used
Enables API-controller conventions and automatic responses to invalid request input.
How deep it goes
Traces binding and validation through ModelState, then shows how to suppress automatic HTTP 400 responses for manual handling.
Examples
Shows an invalid pageIndex response and Program.cs configuration for suppressing the automatic invalid-ModelState filter.
What you can do after
Operate/configure it to retain automatic validation or inspect ModelState manually when an action needs a custom response.

Read how Building Web APIs with ASP.NET Core explains ApiController →

Related concepts

These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.