The ASP.Net MVC Process Request Life Cycle

What Is ASP.Net MVC Application Life-Cycle?

What Is MVC?
The MVC is a framework, standard pattern for developing Web applications and MVC framework handled by three objects Model, View and Controller.

MVC Application Life-Cycle -

In short - MVC application Life Cycle Steps
1.      Creating the request object -
a.      Fill route
b.      Fetch route
2.      Request context created
3.      Controller instance created
4.      Creating Response object

MVC Application Life Cycle Steps - In detail
Firstly, I am going to share the MVC process request and after will discuss over the process request life cycle.

When you send the request to MVC application that means you are directly calling the controller's ActionMethod i.e. http://localhost:42955/Customers/Index

In the above requested URL, Customers is a controller and Index is an ActionMethod that directly calling to action method for a particular controller.

Process Request Life Cycle -

Step 1When you send a request to MVC Applications.
Step 2Create an instance of the RouteTable class.  It does create the first time when your MVC application start.

The RouteTable class hold the collection of objects and it does derive from the RouteBase class.

Step 3After that, the UrlRoutingModule interrupt each and every request and find you’re matching RouteData from your RouteTable and create an instance of MVC Handler as the HttpHandler.

Step 4After that, the MVC handler is create the DefaultControllerFactory. Its process the RequestContext and get the specific controller that you called and it’s create the ControllerContext and execute the controller.

Step 5After that, get the ActionMethod from the RouteData and builds controller's ActionMethod based on your request.

Step 6After that, the ActionMethod returns the ActionResult and renders the view.

You can see in the below images-

Anil Singh is an author, tech blogger, and software programmer. Book writing, tech blogging is something do extra and Anil love doing it. For more detail, kindly refer to this link..
My Blogs - and
My Book2 - ANGULAR 2 INTERVIEW QUESTIONS BOOK - Both Books are Available on WorldWide. Powered by Blogger.