一区二区久久-一区二区三区www-一区二区三区久久-一区二区三区久久精品-麻豆国产一区二区在线观看-麻豆国产视频

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

系列文章導(dǎo)航:

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

[一步一步MVC]第二回:還是ActionFilter,實現(xiàn)對業(yè)務(wù)邏輯的統(tǒng)一Authorize處理

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

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

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

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


引言

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

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

我們先來了解這幾個概念之間的聯(lián)系。

 

o_anytao-mvc-09-01[1]

對MVC而言,分離是最大的優(yōu)點,尤其是Model將不依賴于Controller和View,對于隔離應(yīng)用、進(jìn)行UI測試打下很好的架構(gòu)級支持。

MVC Execution Process

關(guān)于MVC的執(zhí)行過程,我們就不多言了,從MSDN獲取的執(zhí)行過程可以被解析為:

o_anytao-mvc-09-02[1] 

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

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技術(shù)[一步一步MVC]第六回:什么是MVC(上)?,轉(zhuǎn)載需保留來源!

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

主站蜘蛛池模板: 91成人免费版 | 国产成人免费高清激情视频 | 黄网站在线免费 | 国产成人一区免费观看 | 丁香婷婷综合五月六月 | 2021国产成人精品国产 | 青青久久久国产线免观 | 亚洲fuli在线观看 | 久久大香萑太香蕉综合网 | 一区二区中文字幕在线观看 | 免费看污成人午夜网站 | 开心激情久久 | 亚洲二区在线观看 | 亚洲视频一区在线 | 蕾丝视频成人★在线观看 | 高清视频一区二区三区 | 欧美一级特黄高清免费 | 婷婷六月在线 | 国产h视频在线观看网站免费 | 色婷婷久久综合中文久久一本` | 九色国产在视频线精品视频 | 一区卡二区卡三区卡视频 | 久久综合久久综合久久 | 高清一区二区三区四区五区 | 久久精品国产99久久72 | 久久爆操 | 色婷婷激情五月综合 | 亚洲成a人片在线v观看 | 成人污视频在线观看 | 久久精品网站2019精品 | 色老板在线视频观看 | 国产精品高清视亚洲一区二区 | 国产真实伦在线视频免费观看 | 亚洲手机国产精品 | 91最新在线观看 | 久久成人永久免费播放 | 色多多免费视频观看区一区 | 亚洲系列中文字幕一区二区 | 中文字幕色站 | 国产精品被窝福利一区 | 美女一级毛片免费观看 |