The MVC pattern

The MVC pattern divides the application into three separated layers — models, views, and controllers — each with different responsibilities:

  • Models: Responsible for data, retrieving it from data storage, and passing it on throughout the other layers of the application.
  • Views: Responsible for generating the output of the application, mainly in HTML documents.
  • Controllers: The glue between all the application layers. Controllers react on user requests, ask for data from the model layer, and pass the needed information to the view to generate an output.

Additionally, ASP.NET Core MVC applications rely on another component: the request router. This component is responsible for understanding the request target, usually by its URL, and executing the matching controller.

The execution flow is described in the following diagram:

The following is a description of the preceding diagram:

  1. A request is received from the end user.
  2. The router decides on the relevant controller to handle the request based on the request properties. The matching controller method is then executed.
  3. The controller method, in turn, asks for needed data from the model layer.
  4. The model layer communicates with the data storage.
  5. The model layer retrieves the requested data.
  6. The data is returned to the controller, which then sends it to the view.
  7. The view dynamically generates the output based on the data.
  8. The generated view is returned to the controller.
  9. The controller responds to the user with the generated output.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.15.144.56