ControllerBase is the usual base class for ASP.NET Core web API controllers. It supplies controller infrastructure and helper methods for generating HTTP results, without the Razor view features associated with the MVC Controller class. section 20.1
A ControllerBase-derived controller typically works with:
- [ApiController], which applies common web API conventions. section 20.1
- Action methods that return data directly or return ActionResult values for conditions such as not found. section 20.1
- Routing attributes such as [HttpGet("fruit")] to expose actions as HTTP endpoints. section 20.1
A small web API controller
Declare `public class FruitController : ControllerBase`, add `[ApiController]`, and define an `[HttpGet("fruit")]` action returning `IEnumerable<string>`. A GET request to `/fruit` returns the list as JSON with a 200 OK response. An action returning `ActionResult<string>` can instead call `NotFound()` when an identifier is invalid.

