ApiController
ApiController is an ASP.NET Core attribute that enables API-specific conventions and behavior for controller classes, including request binding and validation handling.
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
- ModelState.IsValidcontrasts with · An ASP.NET Core property indicating whether model binding and validation completed without errors.
- automatic 400 responsesproduces · Automatic 400 responses are framework-generated Bad Request responses produced when API model validation fails.
- automatic model state validationconfigures · Automatic model state validation is the framework behavior that short-circuits an API action with a client-error response when ModelState is invalid.
- explicit routingconfigures · Explicit routing is a routing approach in which each endpoint is assigned a specific URL pattern directly, often through route templates or attributes.
- Problem Detailsproduces · Problem Details is a standardized HTTP response format for communicating machine-readable information about a problem occurrence, commonly serialized as JSON.
- validationconfigures · The process of checking data, behavior, systems, models, or results against defined criteria to assess their correctness, suitability, or acceptability.
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.

