一、应用程序启动
1.Application_Start方法,程序启动

2.RegisterRoutes方法,注册路由

3.System.Web.Mvc.RouteCollectionExtensions.MapRoute方法,出现了MvcRoutehandler对象

二、请求进入
在 “$\Windows\Microsoft.NET\Framework\版本号\Config\Web.config“ 中可以找到 " <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" />”
证明请求会经过System.Web.Routing.UrlRoutingModule.Init方法。
1.System.Web.Routing.UrlRoutingModule.Init方法

2.System.Web.Routing.UrlRoutingModule.PostResolveRequestCache方法

3.System.Web.Routing.RouteCollection.GetRouteData方法

4.System.Web.Routing.Route.GetRouteDara方法

这里的this.RouteHandler就是在第一部分中应用程序启动是实例化好的MvcRouteHandler对象。好了,我们现在已经得到了MvcRouteHandler实例,继续向下走,先返回第2步:
2.System.Web.Routing.UrlRoutingModule.PostResolveRequestCache方法

3. System.Web.Mvc.MvcRouteHandler.GetHttpHandler方法,返回MvcHandler对象

4.System.Web.Mvc.MvcHandler的构成方法

发现这个类实现了IHttpHandler接口,那么不得不去看下ProcessRequest方法
5.System.Web.Mvc.MvcHandler.ProcessRequest方法

6.System.Web.Mvc.MvcHandler.ProcessRequestInit方法

返回到第5步
5.System.Web.Mvc.MvcHandler.ProcessRequest方法

6.System.Web.Mvc.ControllerBase.Excete方法

7.System.Web.Mvc.Controller.ExcuteCore方法

8.System.Web.Mvc.Controller.ActionInvoker属性

9.System.Web.Mvc.Controller.CreateActionInvoker方法

返回了实现IActionInvoker接口的实例,返回第7步
7.System.Web.Mvc.Controller.ExcuteCore方法

8.System.Web.Mvc.ControllerActionInvoker.InvokeAction方法

9.System.Web.Mvc.ControllerActionInvoker.InvokeActionResult方法

10.System.Web.Mvc.ActionResult类,封装一个操作方法的结果

我们来看一下重写了ExcuteResult的ActionResult的派生类:

我们就选ViewResultBase类中的ExcuteResult方法看看
11.System.Web.Mvc.ViewResultBase.ExcuteResult方法

12.System.Web.Mvc.ViewResult.ExcuteResult方法

13.System.Web.Mvc.ViewEngineCollection.FindView方法

14.System.Web.Mvc.VirtualPathProviderViewEngine.FindView方法

返回第13步
13.System.Web.Mvc.ViewEngineCollection.FindView方法

14.System.Web.Mvc.ViewEngineCollection.Find方法

15.System.Web.Mvc.ViewEngineCollection.Find方法

至此,我们得到了ViewEngineResult对象,ViewEngineResult表示定位视图引擎的结果。
现在我们返回第11步,继续向下走
11.System.Web.Mvc.ViewResultBase.ExcuteResult方法

12.System.Web.Mvc.BuildManagerCompiledView.Render方法

13. System.Web.Mvc.RazorView.RenderView方法,在这里使用Razor视图引擎来展示页面
