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
Reduces repetitive code and applies consistent conventions to ASP.NET Core web API controllers.
How deep it goes
Compares controllers with and without the attribute, explains its conventions, and demonstrates configuration and a validation-filter alternative.
Examples
Uses a fruit-list GET endpoint and an update action with a required name to illustrate controller behavior.
What you can do after
Apply it via ASP.NET Core to simplify controllers and configure automatic validation behavior.

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 →

Also covered in

What to know first

Related concepts

Questions about ApiController

What is ApiController?

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

Which Manning books explain ApiController?

ASP.NET Core in Action, 3e and Building Web APIs with ASP.NET Core.

What should I know before learning ApiController?

Manning books that teach ApiController usually introduce 400 bad request, JSON, model binding and Model–view–controller first.

What is the difference between ApiController and ModelState.IsValid?

ApiController is an ASP.NET Core attribute that enables API-specific conventions and behavior for controller classes, including request binding and validation handling. An ASP.NET Core property indicating whether model binding and validation completed without errors.

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.