官术网_书友最值得收藏!

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.
主站蜘蛛池模板: 呼伦贝尔市| 天镇县| 玉门市| 石狮市| 深泽县| 呼图壁县| 沙田区| 长兴县| 靖西县| 墨江| 阜南县| 凤山县| 岐山县| 镇宁| 铅山县| 河西区| 古田县| 孟津县| 贺兰县| 民县| 北海市| 博湖县| 定襄县| 寻乌县| 扎赉特旗| 乐陵市| 扶绥县| 信丰县| 普兰店市| 进贤县| 横峰县| 诏安县| 永定县| 黑山县| 苏尼特左旗| 宁波市| 康平县| 伊宁县| 拉孜县| 上犹县| 南投县|