Role of the Controller in ASP.NET MVC applications
At the high level, the Controller orchestrates between the Model and the View, and sends the output back to the user. This is also the place where authentication is usually done through action filters. Action filters will be discussed in detail in the Filters section of this chapter. The following figure illustrates the high-level flow of a request (with the steps) in ASP.Net MVC and shows us how the Controller fits into the big picture:
The following is the sequence of events that will happen at high level when the user is accessing the ASP.NET Core application:
The user types the URL in the browser.
Based on the pattern of the URL, the routing engine selects the appropriate Controller.
The Controller talks to the Model to get any relevant data through its action methods. Action methods are methods within a
controller
class.The Controller then passes the data to the View to present it in a viewable format, typically as HTML elements.
The View...