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

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.
主站蜘蛛池模板: 若羌县| 兰州市| 囊谦县| 迁安市| 温宿县| 公安县| 巨野县| 宝坻区| 大冶市| 财经| 昆明市| 池州市| 古浪县| 遂溪县| 永寿县| 巢湖市| 华坪县| 闵行区| 许昌县| 额敏县| 郓城县| 荆门市| 金阳县| 云南省| 临漳县| 鄂托克旗| 衢州市| 海林市| 海门市| 石阡县| 松潘县| 达孜县| 慈利县| 忻城县| 郴州市| 闽清县| 资讯 | 徐汇区| 额尔古纳市| 磐安县| 玉田县|