From version 2.1, ASP.NET Core introduced a new attribute, that is, the ApiController attribute:
using Microsoft.AspNetCore.Mvc;namespace SampleAPI.API.Controllers{ [Route("api/[controller]")] [ApiController] public class ValuesController : ControllerBase { // ... }{
The ApiController attribute is commonly coupled with the ControllerBase class to enable REST-specific behavior for controllers, and it allows us to build HTTP APIs. First of all, it provides implicit model state validation, which means that we do not need to explicitly check the ModelState.IsValid attribute in each action. Secondly, it also implicitly defines the model binding attributes, which means that we do not need to specify the [FromBody], ...