In this chapter, we’ll discuss the MVC pipeline and therefore the lifetime of associate protocol request because it travels through the MVC framework in ASP.NET. At a high level, a life cycle is solely a series of steps or events wont to handle some style of request or to alter associate application state. you’ll already be aware of varied framework life cycles, the conception isn’t distinctive to MVC.
For example, the ASP.NET webforms platform options a posh page life cycle. Other .NET platforms, like Windows phone apps, have their own application life cycles. One issue that’s true for of these platforms no matter the technology is that understanding the process pipeline will assist you higher leverage the options obtainable and MVC isn’t any totally different.
MVC has 2 life cycles −
- The application life cycle
2. The request life cycle
The Application Life Cycle
The application life cycle refers to the time at that the appliance method really begins running IIS till the time it stops. this can be marked by the appliance begin and finish events within the startup file of your application.
The Request Life Cycle
It is the sequence of events that happen on every occasion associate protocol request is handled by our application.
The entry purpose for each MVC application begins with routing. when the ASP.NET platform has received a call for participation, it figures out however it ought to be handled through the address Routing Module.
Modules square measure .NET parts which will hook into the appliance life cycle and add practicality. The routing module is answerable for matching the incoming address to routes that we tend to outline in our application.
All routes have associate associated route handler with them and this can be the entry purpose to the MVC framework.
The MVC framework handles changing the route knowledge into a concrete controller which will handle requests. when the controller has been created, following major step is Action Execution. A element known as the action invoker finds associated selects an acceptable Action technique to invoke the controller.
After our action result has been ready, following stage triggers, that is Result Execution. MVC separates declaring the result from execution the result. If the result’s a read sort, the read Engine are known as and it’s answerable for finding and ripping our read.
If the result’s not a read, the action result can execute on its own. This Result Execution is what generates associate actual response to the initial protocol request.