Controller in an ASP.NET MVC
Controllers are essentially the central unit of your ASP.NET MVC application. It is the 1st recipient, which interacts with incoming HTTP Request and responsible for controlling the flow of the application execution.
The controller decides which model will be selected, and then it takes the data from the model and passes the same to the respective view, after that view is rendered
Controller class contains a set of public methods called action methods or simple actions. All controller class must be named by using the “Controller” suffix.
It uses the WebFormViewEngine class for rendering ASP.NET page.
Rather then having a direct relationship between the URL and a file living on the webserver, there is a relationship between the URL and a the method on a controller class.
Controllers are C# classes that derive from the built-in controller base class, System.Web.Mvc.Controller.
Each public method in a controller is referred to as an action method, which means you can use a URL to call it from the Web to carry out an action.
How Controller Works
The Controller receives the input as form values, query strings etc, perfrom required operations on the user inputs with the help of Model and passing the result back to the view or partical view.
Methos or Action inside the Controller classes are called by the routing suystem to process a particular request.
The Controller class is the place where the developers write the actual code required to serve a request.
Creating a Controller
Do right click on the controller folder in Server Explorer and select option 'Add Controller'