Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • ASP.NET MVC Life Cycle

    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 0
    • 313
    Comment on it

    In a MVC application the requests are routed to a special class called the Controller. The controller is responsible for generating the response and sending the content back to the browser. When an MVC application receives request the action method of a controller is invoked and appropriate response is generated and sent back to the client.


    Following are the major steps involved when you make a request to an Asp.net MVC web application.

    1) Routing

    Asp.net Routing is the starting point in MVC request cycle. In this step the system matches the requests URL against the registered URL patterns in the Route Table. In case a a matching RouteData is found from RouteTable than a MVCHandler (an HttpHandler) is instantiated. If no match is found routing engine returns a 404 HTTP status code. An instance of the RouteTable class is created on application start which is setup in the Global.asax file of the application,this happens only when the application is requested for the first time.


    2) MvcHandler

    The MvcHandler is responsible for initiating the real processing . The MVCHandler creates a DefaultControllerFactory. The DefaultControllerFactory processes the RequestContext and gets a specific controller.


    3) Controller

    Once the controller(containing the user defined logic) has been instantiated, controller's ActionInvoker determines which specific action to invoke on the controller. The ActionInvoker class has the responsibility of finding the action method in the controller and then invoking the action method.


    4) ActionResult

    The action method receives user input and creates the response data, and then finallly returns a result type. The result type can be ViewResult, RedirectToRouteResult, RedirectResult, ContentResult, JsonResult, FileResult, and EmptyResult.


    5) View Engine

    The first step in the execution of the View Result is selecting the right View Engine. It is handled by IViewEngine interface of the view engine. By default Asp.Net MVC provides WebForm and Razor view engines. A View Engine is responsible for rendering HTML to the browser.

 0 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: