ASP. NET MVC - Lifecycle
Asp.net mvc tutorial
ASP.NET MVC - Lifecycle
In this chapter, we will discuss the overall MVC pipeline and the lifetime of an HTTP request during of his journey in the MVC framework in ASP.NET. At a high level, a lifecycle is simply a series of steps or events that are used to process some type of request or to change the state of an application. You may already be familiar with
For example, the ASP.NET Web Forms Platform exhibits a complex page lifecycle. Other .NET platforms, like Windows Phone apps, have their own app lifecycles. One thing that is true for all of these platforms, regardless of technology, is that understanding the processing pipeline can help you better exploit the features available and MVC is no different.
MVC has two lifecycles -
- The life cycle of the application
- The life cycle of the query
The lifecycle of the application
The lifecycle Application Time refers to the time when the application process actually starts running IIS until it stops. This is marked by the application start and end events in your application startup file.
This is the sequence of events that occur each time an HTTP request is handled by our application.
The entry point of every MVC application begins with routing. After the ASP.NET platform receives a request, it determines how it should be handled through the URL routing module.
Modules are .NET components that can plug into the application lifecycle and add functionality. The routing module is responsible for matching the incoming url to routes that we define in our application.
All routes have a route manager associated with them and this is the entry point to the MVC framework.
The MVC framework handles the conversion of the route data into a concrete controller that can handle requests. Once the controller is created, the next major step is execution of the 'action . A component called an action invoker finds and selects an appropriate action method to call the controller.
After the result of our prepared action, the next step is triggered, which is Executing results . MVC separates the declaration of the result from the execution of the result. If the result is a view type, the output engine visualization will be called and it will be responsible for finding and rendering our view.
If the result is not a view, the result of the action will execute on its own This result execution is what generates an actual response to theoriginal HTTP request.