Sunday, May 19, 2019

Asp.Net MVC Page Life Cycle Phase I

When we talk about Asp.Net web form page life  cycle, there was lot of events which
are fired during page load.  But in MVC  there are no events as we know  so it works based on routing.Therefore routing term is very  important  when we talk about Asp.Net MVC.


 So in this phase I will only describe about routing.   I am giving some ideas about web form working. When    request comes for .aspx page then each aspx page implement
IHTTPHandler interface which executes process request    method to generate the response.

 However Asp.Net MVC application does not work in   this way. There is no physical page exists for particular   request. All the requests are routed to controller.   Which controller is responsible for return back response   to the browser.


 In MVC application you can create multiple controllers   and each controller can handle multiple actions in other way   we can say multiple pages.

 So, we will try to understand how these request are routed to particular   controller. Now route  table  came into the picture.   Each Asp.Net MVC application contains route table.   This route table is responsible to map the mvc request   to particular controller.

 When application starts very first Application_Start   method is called which is available in   global.asax.cs   page. In this method we register the routes by calling   RegisterRoute method. Which creates the route table and send   the collection of routes as a parameter that are added
   to the to this collection.

   We will discuss more on routes in the next blog.

No comments:

Post a Comment