Understanding Controllers
Learn to understand the details of Web API resources by utilizing controllers in this lesson.
We'll cover the following...
Implementation of web API resources using controllers
Web API resources are implemented using controllers. Let’s have a look at the controller that the template project created by opening WeatherForecastController.cs
in the Controllers
folder. This contains a class called WeatherForecastController
that inherits from ControllerBase
with a Route
annotation:
Press + to interact
[ApiController][Route("[controller]")]public class WeatherForecastController : ControllerBase {...}
The annotation specifies the web API resource URL that the controller handles. The [controller]
...