Broadly speaking, a controller is a class with a group of methods called actions. An action, also known as an action method, is a method that handles the request. As per the convention used by the ASP.NET Core MVC framework, a controller is a class that:
- Is instantiable; that is, an instance of that class can be created
- Resides in the project's root-level folder, named Controllers
- Inherits from an abstract class, Microsoft.AspNetCore.Mvc.Controller
The framework is flexible and would also treat an instantiable class as a controller if any one or more of the following holds good:
- The class is decorated with the [Controller] attribute
- The class name is suffixed with Controller, such as HomeController
- The class derives from a ...