API Controllers Flashcards

1
Q

What is the class that an API controller inherits from? What does it do?

A
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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the two main attributes that we use with an API controller?

A

[Route(“api/[controller”])] and [ApiController]

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is Web API routing and what are the two main ways of implementation?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is attribute routing?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly