天天躁日日躁狠狠躁AV麻豆-天天躁人人躁人人躁狂躁-天天澡夜夜澡人人澡-天天影视香色欲综合网-国产成人女人在线视频观看-国产成人女人视频在线观看

[一步一步MVC]第六回:什么是MVC(上)?

系列文章導航:

[一步一步MVC]第一回:使用ActionSelector控制Action的選擇

[一步一步MVC]第二回:還是ActionFilter,實現對業務邏輯的統一Authorize處理

[一步一步MVC]第三回:MVC范例大觀園

[一步一步MVC]第四回:漫談ActionLink,有時“胡攪蠻纏”

[一步一步MVC]第五回:讓TagBuilder豐富你的HtmlHelper

[一步一步MVC]第六回:什么是MVC(上)?


引言

所謂MVC,其實就是M、V、C而已。歸根揭底,MVC是一種表現模式,是一種軟件架構模式。其中有幾個重要的概念:

  • M,Model, 引用系統數據,管理系統功能并通知View更改用戶操作。
  • V,View,就是用戶接口,用于顯示數據。
  • C,Controller ,將用戶操作映射到Model,并操作視圖。
  • R,Routing ,MVC的奧秘在于通過Routing實現了對URL的路由選擇,完成了上述3個基本概念的基礎邏輯。

我們先來了解這幾個概念之間的聯系。

 

o_anytao-mvc-09-01[1]

對MVC而言,分離是最大的優點,尤其是Model將不依賴于Controller和View,對于隔離應用、進行UI測試打下很好的架構級支持。

MVC Execution Process

關于MVC的執行過程,我們就不多言了,從MSDN獲取的執行過程可以被解析為:

o_anytao-mvc-09-02[1] 

在MVC模式下,不同于WebForm時代,業務邏輯的處理和HTML的輸出不是View(或Page)一個人的事兒,這些邏輯被清晰的分解為M、V和C的邏輯,具體的執行流程為:

ASP.NET MVC Execution Process

Stage

Details

Receive first request for the application

In the Global.asax file, Route objects are added to the RouteTable object.

void Application_Start(object sender, EventArgs e) {    RegisterRoutes(RouteTable.Routes);}public static void RegisterRoutes(RouteCollection routes){    routes.Add(new Route    (         "Category/{action}/{categoryName}"         , new CategoryRouteHandler()    ));}

Perform routing

The UrlRoutingModule module uses the first matching Route object in the RouteTable collection to create the RouteData object, which it then uses to create a RequestContext object.

 

Create MVC request handler

The MvcRouteHandler object creates an instance of the MvcHandler class and passes the RequestContext instance to the handler.

Create controller

The MvcHandler object uses the RequestContext instance to identify the IControllerFactory object (typically an instance of the DefaultControllerFactory class) to create the controller instance with.

Execute controller

The MvcHandler instance calls the controller's Execute method.

Invoke action

For controllers that inherit from the ControllerBase class, the ControllerActionInvoker object that is associated with the controller determines which action method of the controller class to call, and then calls that method.

Execute result

The action method receives user input, prepares the appropriate response data, and then executes the result by returning a result type. The built-in result types that can be executed include the following: ViewResult (which renders a view and is the most-often used result type), RedirectToRouteResult, RedirectResult, ContentResult, JsonResult, FileResult, and EmptyResult.

NET技術[一步一步MVC]第六回:什么是MVC(上)?,轉載需保留來源!

鄭重聲明:本文版權歸原作者所有,轉載文章僅為傳播更多信息之目的,如作者信息標記有誤,請第一時間聯系我們修改或刪除,多謝。

主站蜘蛛池模板: 免费看男人J放进女人J无遮掩 | 国产日韩精品一区二区在线观看 | 精品国产自在自线官方 | 嫩草影院在线观看精品 | 亚洲高清免费在线观看 | 欧美黄色xxx | 一扒二脱三插片在线观看 | 亚洲免费国产在线日韩 | 特黄AAAAAAA片免费视频 | 新版孕妇bbwbbwbbw| 在线视频一区二区三区在线播放 | 偷窥自拍性综合图区 | 人妻中文字幕无码系列 | 妺妺窝人体色WWW偷窥女厕 | 国产成人精品视频播放 | 国产精品99久久久久久人韩国 | 亚洲AV久久婷婷蜜臀无码不卡 | 东北小伙FREECHINESE野外 东北嫖妓对白粗口 | 久久AV亚洲精品一区无码网 | 亚洲免费精品 | 国外色幼网 | 亚洲精品成A人在线观看 | 麻豆产精品一二三产区区 | 欧美日韩亚洲中字二区 | 中文字幕亚洲欧美日韩2019 | 亚洲综合国产在不卡在线 | 久久久久久久国产精品视频 | 国产99热在线观看 | 真实国产乱子伦精品一区二区三区 | 国产午夜精品一区二区理论影院 | 国产亚洲人成网站在线观看播放 | 毛片一区二区三区 | 国产成人免费片在线视频观看 | 姑娘视频日本在线播放 | 国产成人无码精品久久久按摩 | 久久怡红院国产精品 | 一一本之道高清视频在线观看中文字幕 | 精品久久综合1区2区3区激情 | 红番阁免费观看 | 午夜黄视频 | 九九热免费在线观看 |