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

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.
主站蜘蛛池模板: 同德县| 行唐县| 恩平市| 龙南县| 梅河口市| 贵州省| 朝阳区| 阜宁县| 化州市| 玛曲县| 城市| 胶州市| 古田县| 泰州市| 仁寿县| 吴忠市| 沙田区| 博乐市| 宽城| 昌都县| 万山特区| 沙坪坝区| 普安县| 安陆市| 新巴尔虎右旗| 恩施市| 浦城县| 武邑县| 游戏| 大丰市| 奇台县| 郎溪县| 阿图什市| 永德县| 白城市| 定西市| 盘锦市| 东方市| 平山县| 衡阳县| 工布江达县|