December 2019
Intermediate to advanced
510 pages
11h 33m
English
Controllers are a fundamental part of the web API in ASP.NET Core projects. They handle incoming requests and act as the entry point of our application. We'll look at controllers in more detail in Chapter 4, Dependency Injection, but for now, let's examine the default WeatherForecastController provided by the web API template:
using System;using System.Collections.Generic;using System.Linq;using Microsoft.AspNetCore.Mvc;using Microsoft.Extensions.Logging;namespace SampleAPI.Controllers{ [ApiController] [Route("[controller]")] public class WeatherForecastController : ControllerBase { private static readonly string[] Summaries = new[] { "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", "Hot", "Sweltering" ...
Read now
Unlock full access