The MVC Request Life Cycle

This course introduces ASP.NET developers, specifically MVC developers, to the life cycle of an HTTP request as it travels through the ASP.NET platform and the MVC framework.
Course info
Rating
(810)
Level
Intermediate
Updated
Jun 3, 2015
Duration
2h 32m
Table of contents
Overview
The Application and Request Life Cycle Events
Working with Routing, HttpHandlers, and HttpModules
Understanding Controller Initialization
Action Method Execution
Exploring Action Results and the View Engine
Description
Course info
Rating
(810)
Level
Intermediate
Updated
Jun 3, 2015
Duration
2h 32m
Description

This course introduces ASP.NET developers, specifically MVC developers, to the life cycle of an HTTP request as it travels through the ASP.NET platform and the MVC framework. The course will educate developers about the major steps in the Request Life cycle, as well as how to extend and customize them when appropriate. The focus of the course will not be on MVC coding and how to build applications, but rather on the relationships between the components that comprise the request pipeline. The inner workings of the MVC framework will also be discussed where applicable, such as Controller Factories, Dependency Resolvers, and Result Execution.

About the author
About the author

Alex Wolf is passionate about software development and mastering new technologies. He has several years of experience working almost exclusively with the .NET Framework and related platforms. Alex is also a Microsoft Certified Professional in both MVC Application development and HTML 5 technologies. He loves learning new things!

More from the author
Android: Image Processing with Picasso
Beginner
1h 57m
9 Mar 2018
Android: Getting Started with Retrofit
Beginner
2h 20m
10 Jan 2018
More courses by Alex Wolf
Section Introduction Transcripts
Section Introduction Transcripts

The Application and Request Life Cycle Events
In this module we're going to explore the ASP. NET request and application life cycle events. Understanding these events is really important to learning how MVC integrates into the larger ASP. NET pipeline. Now I also want to tell you up front that it's difficult to discuss these life cycle events without mentioning Http Handlers and modules. So if you aren't familiar with these components, just follow along for now and in the next module things will really start to fall into place when we discuss those components in more depth. For now we'll begin by discussing what happens with an application receives its first request and how we can apply initial startup configurations. We'll even look at how we can apply configurations before the application starts. Next we'll step through the Request Life Cycle events that fire every time a request is processed and we'll look at how MVC plugs into this pipeline. We'll also discuss how and when we might want to tap into the life cycle events ourselves using custom code. So there's no better to start than at the beginning, so let's go ahead and dive in.

Working with Routing, HttpHandlers, and HttpModules
In this module we will discuss HttpModules and HttpHandlers in greater depth. What exactly are these components? When and how would I use them? And most importantly how do they integrate with the MVC pipeline? These are all the types of questions we want to answer in this module. So we'll begin our discussion with an overview of HttpHandlers and walk through an example of how to create our own. We'll repeat this process with HttpModules just to make sure we fully understand both items. We'll compare and contrast them along the way as necessary. We also want to discuss which modules and handlers play a role in the MVC Request pipeline. I've already mentioned some of these concepts in the previous module, but now we really want to explore them in depth and put all the pieces together. So by the end of this module you should have a firm understanding of all of the ASP. NET components that enable and really support the MVC framework's execution.

Exploring Action Results and the View Engine
The final stage of the MVC pipeline is one the most interesting. All of our hard work is finally rendered into a response that can be sent back to the requestor. So in this module we're going to discuss how Action Results execute and the steps involved in that execution. If we reference our MVC Life Cycle chart again, you can see that we're reaching the end of our journey. In the last module we discussed Action Methods and the steps involved in returning an Action Result to the framework. Now we want to explore how the MVC pipeline moves forward, depending on the type of Action Result. There are really two main paths, View Results and everything else, both of which we'll discuss more in another lesson. So this module is probably the most straightforward, but let's look ahead to the specific topics that we'll be covering. First we'll discuss Action Result execution from a high level and the steps that it contributes to the overall MVC pipeline. We'll then reinforce these concepts by building a Custom Action Result of our own. Next we want to spend some time exploring View Results. These are an important type of Action Result that involve other components as well, such as the View Engine. We'll walk through how to customize and extend View functionality to really understand how everything fits together. By the end of this module you should have a firm grasp on the final stages of the Request Life Cycle.