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

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.
主站蜘蛛池模板: 太和县| 武山县| 天津市| 民勤县| 阿图什市| 武平县| 招远市| 新龙县| 永川市| 江油市| 黄梅县| 尚志市| 陇西县| 揭阳市| 周宁县| 和政县| 封丘县| 乾安县| 江门市| 广南县| 准格尔旗| 若尔盖县| 股票| 汕头市| 江城| 牡丹江市| 崇明县| 鹰潭市| 固镇县| 四平市| 报价| 平果县| 台东市| 若尔盖县| 保亭| 信阳市| 武强县| 镇安县| 巴林左旗| 巴塘县| 炉霍县|