The following are the stages of execution for an MVC Web project.
-
In the Global.asax file, Route objects are added to the RouteTable object.
-
The UrlRoutingModule module uses the first matching Route object in the RouteTablecollection
to create the RouteData object, which it then uses to create a RequestContext(IHttpContext) object.
-
The MvcRouteHandler creates an instance of the MvcHandler and passes it the RequestContext instance.
-
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.
-
The MvcHandler instance calls the controller's Execute method.
-
Most controllers inherit from the Controller base class. For controllers that do so,
theControllerActionInvoker object that is associated with the controller determines which
action method of the controller class to call, and then calls that method.
-
A typical action method might receive user input, prepare the appropriate response data,
and then execute 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 and JsonResult.
The following diagram shows the stages of execution for an MVC Web project.
Summary
In this article, we looked at the ASP.net MVC application execution process. In next article we will look at MVC application structure.