Tuesday, April 19, 2011

MVC Application Execution Process (C#)


  1. When Receive first request for the application-
    In the Global.asax file, Route objects are added to the RouteTable object
  2. 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 (IHttpContext) object.
  3. Create MVC request handler -
    The MvcRouteHandler object creates an instance of the MvcHandler class and passes it the RequestContext instance.
  4. 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.
  5. Execute controller -
    The MvcHandler instance
    calls the controller s Execute method.
  6. Invoke action -
    Most controllers inherit from the Controller base class. For controllers that do so, the ControllerActionInvoker object that is associated with the controller determines which action method of the controller class to call, and
    then calls that method.
  7. Execute result -
    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, JsonResult, and
    EmptyResult
    .

No comments:

Post a Comment