API Controllers Flashcards
What is the class that an API controller inherits from? What does it do?
ControllerBase. It's a built-in base class for an MVC controller without view support.
ASP requires that all controllers implement IController interface. It provides several methods and properties.
What are the two main attributes that we use with an API controller?
[Route(“api/[controller”])] and [ApiController]
What is Web API routing and what are the two main ways of implementation?
Convention based routing and Attribute routing.
ASP.NET Core routes incoming HTTP requests by parsing it and matching it to an action in a controller. ASP.NET Core suggests we only use attribute routing for APIs.
What is attribute routing?
An implementation of routing that uses attributes to map routes directly to the action methods inside a controller.
The base route attribute is placed above the controller and for each specific action we create their route with attributes above them.