Controllers are responsible for the workflow of the application. They retrieve user requests, work with the model, and then choose the view to render.
Controllers in ASP.NET Core MVC are C# classes that reside under the Controllers directory and inherit from Microsoft.AspNetCore.Mvc.Controller. Controller classes must match one of the following rules as well:
- The class name ends with Controller, for example, UsersController
- The class inherits from a class whose name ends with Controller
- The class is decorated with the [Controller] or [ApiController] attribute
Public methods inside controller classes are also called actions. Each action handles a different request from end users and generates output. Usually, a controller class ...