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 the
process request life cycle.
When you
send the request to the 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 calls to an action
method for a particular controller.
Process
Request Life Cycle -
Step 1: When you send a request to MVC
Applications.
Step 2: Create an instance of the
RouteTable class. It does create the first time when your MVC application
starts.
The RouteTable class holds the collection of objects
and it does derive from the RouteBase
class.
Step 3: After that, the UrlRoutingModule interrupts each and every request
and finds you’re matching RouteData from
your RouteTable and create an instance of MVC Handler as the HttpHandler.
Step 4: After that, the MVC handler creates the DefaultControllerFactory. It
processes the RequestContext and gets the specific controller that you called and it creates the ControllerContext and executes the controller.
Step 5: After that, get the ActionMethod
from the RouteData and builds the controller's ActionMethod based on your request.
Step 6: After that, the ActionMethod
returns the ActionResult and renders the view.
You can
see in the below images-