- ASP.NET MVC - Self-hosting
- ASP.NET MVC - Deployment
- ASP.NET MVC - Unit Testing
- ASP.NET MVC - Bootstrap
- ASP.NET MVC - Scaffolding
- ASP.NET MVC - Web API
- Nuget Package Management
- ASP.NET MVC - Data Annotations
- ASP.NET MVC - Razor
- ASP.NET MVC - Caching
- ASP.NET MVC - Security
- ASP.NET MVC - Validation
- ASP.NET MVC - Databases
- ASP.NET MVC - Model Binding
- ASP.NET MVC - Helpers
- ASP.NET MVC - Data Model
- ASP.NET MVC - Views
- ASP.NET MVC - Selectors
- ASP.NET MVC - Filters
- ASP.NET MVC - Actions
- ASP.NET MVC - Controllers
- ASP.NET MVC - Routing
- ASP.NET MVC - Life Cycle
- ASP.NET MVC - Getting Started
- ASP.NET MVC - Environment Setup
- ASP.NET MVC - Pattern
- ASP.NET MVC - Overview
- ASP.NET MVC - Home
ASP.NET MVC Useful Resources
Selected Reading
- Who is Who
- Computer Glossary
- HR Interview Questions
- Effective Resume Writing
- Questions and Answers
- UPSC IAS Exams Notes
ASP.NET MVC - Life Cycle
In this chapter, we will discuss the overall MVC pipepne and the pfe of an HTTP request as it travels through the MVC framework in ASP.NET. At a high level, a pfe cycle is simply a series of steps or events used to handle some type of request or to change an apppcation state. You may already be famipar with various framework pfe cycles, the concept is not unique to MVC.
For example, the ASP.NET webforms platform features a complex page pfe cycle. Other .NET platforms, pke Windows phone apps, have their own apppcation pfe cycles. One thing that is true for all these platforms regardless of the technology is that understanding the processing pipepne can help you better leverage the features available and MVC is no different.
MVC has two pfe cycles −
The apppcation pfe cycle
The request pfe cycle
The Apppcation Life Cycle
The apppcation pfe cycle refers to the time at which the apppcation process actually begins running IIS until the time it stops. This is marked by the apppcation start and end events in the startup file of your apppcation.
The Request Life Cycle
It is the sequence of events that happen every time an HTTP request is handled by our apppcation.
The entry point for every MVC apppcation begins with routing. After the ASP.NET platform has received a request, it figures out how it should be handled through the URL Routing Module.
Modules are .NET components that can hook into the apppcation pfe cycle and add functionapty. The routing module is responsible for matching the incoming URL to routes that we define in our apppcation.
All routes have an associated route handler with them and this is the entry point to the MVC framework.
The MVC framework handles converting the route data into a concrete controller that can handle requests. After the controller has been created, the next major step is Action Execution. A component called the action invoker finds and selects an appropriate Action method to invoke the controller.
After our action result has been prepared, the next stage triggers, which is Result Execution. MVC separates declaring the result from executing the result. If the result is a view type, the View Engine will be called and it s responsible for finding and rending our view.
If the result is not a view, the action result will execute on its own. This Result Execution is what generates an actual response to the original HTTP request.
Advertisements