AddControllers registers the services required for ASP.NET Core web API controllers, without registering Razor view-rendering services. It is the controller-service choice for a web API project rather than an MVC application that renders views. section 20.1
Register controllers in Program.cs
WebApplicationBuilder builder = WebApplication.CreateBuilder(args); builder.Services.AddControllers(); WebApplication app = builder.Build(); app.MapControllers(); app.Run(); AddControllers supplies the controller services; MapControllers exposes controller actions as endpoints. A controller action can then respond to requests such as GET /fruit. section 20.1
