December 2019
Intermediate to advanced
598 pages
12h 21m
English
Web API resources are implemented using controllers. Let's have a look at the controller the template project created by opening WeatherForecastController.cs. This contains a class called WeatherForecastController that inherits from ControllerBase with a Route annotation:
[ApiController][Route("[controller]")]public class WeatherForecastController : ControllerBase{ ...}
The annotation specifies the web API resource URL that the controller handles. The [controller] object is a placeholder for the controller name, minus the word Controller. This controller will handle requests to weatherforecast.
The method called Get in the class is called an action method. Action methods handle specific requests to the resource for ...
Read now
Unlock full access