This course aims to empower .NET developers with a better understanding of the MVC framework and how it works. You'll examine in-depth how an HTTP Request is processed by MVC and .NET Core as it travels through the framework.
Many developers begin their experience with MVC by working with Action Methods, Controllers, Razor Views, and the other essential components of MVC. This is a great place to start, but as the complexity of your projects increases, you may require a deeper understanding of how the framework works internally. You'll also need to understand how MVC integrates with the larger .NET platform. This course, ASP.NET Core: The MVC Request Life Cycle, empowers .NET developers with a better understanding of the MVC pipeline. First, you'll examine how an HTTP Request is processed by MVC and .NET Core as it travels through the framework. Next you'll examine what components are involved at each stage, how they interact with one another, and in some cases how you can customize the default conventions. Understanding how the components of MVC process a request can be extremely helpful on various levels. Finally, you'll learn about how troubleshooting and debugging can often be much easier if you understand what's going on behind the scenes. By the end of this course, you'll have a better understanding of the framework, which will help you build better applications using it.
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!
Course Overview Hey everyone, my name is Alex Wolf, and welcome to this course: ASP. NET Core: The MVC Request Life Cycle. I've been working with MVC since the early days of the framework, so I'm excited to present this updated course on the latest and greatest version. The primary goal of this course is to empower. NET developers with a better understanding of the MVC Pipeline. Many developers become comfortable with general features of MVC, like controllers and action methods, but ultimately reach a point when they need to know more. You might require a deeper understanding to build more complex applications, or just troubleshoot more difficult issues. This course aims to answer questions about how MVC features really work, and how they're integrated together. Questions like: how is a request really translated into a controller and action method? Or how does model binding actually work? What does it mean that MVC is now built on top of a middleware pipeline? Well, we're going to sequentially step through the entire MVC request lifecycle to answer these questions, from the point at which a request is received until a response is finally generated. In this course, we'll cover essential concepts, like how the middleware and routing infrastructure works in MVC. Along the way, we'll delve into the most important components that make these things happen behind the scenes. Now, the MVC pipeline has changed quite a bit in. NET core. Although many of the features have remained largely the same on the surface, some of the underlying technical details have changed significantly. Understanding these differences will allow you to make better design decisions and troubleshoot problems faster. By the end of this course, you'll not only have a deeper understanding of various MVC features, but you'll understand how they are implemented. You'll gain valuable insights for troubleshooting, and better understand the technical implications of design choices in your own apps. I hope you'll join me on this journey to really mastering the MVC framework, with this course: ASP. NET Core: The MVC Request Life Cycle, right here on Pluralsight.
Understanding the Middleware Pipeline In this module, let's begin our tour of the Request Life Cycle by discussing middleware. This topic arguably includes the most significant changes to the entire MVC pipeline. Let's start by revisiting the high level Request Life Cycle diagram from the first module. At the beginning of each module, we'll check in with this diagram to maintain a consistent context for the clips ahead. So in this module, we're going to be discussing the first stage of the life cycle, which again, is the Middleware Pipeline. Middleware provides the essential building blocks of how your application handles an HTTP request, so we're going to cover this topic in depth. We'll begin by discussing exactly what Middleware is, and see the role it plays in handling requests. We'll then explore the main entry point into an MVC application by examining the program class. This component uses another class called Startup to help implement application level configurations and actually assemble the Middleware Pipeline. We'll then start to work with Middleware by building a very simple pipeline of our own, and learn about the different configuration options. Then we'll see how we can extract those Middleware components out into more standalone, reusable classes. Once we are comfortable with Middleware fundamentals, we'll then dive into the MVC Middleware Pipeline in depth. We'll see how this process works behind the scenes, and better understand the essential role that Middleware plays in the MVC Request Life Cycle. Once we're familiar with all the components involved, we'll review how all these pieces are linked together and the general application flow around them. Middleware components also replace much of the functionality of HTTP modules and handlers from previous versions of MVC, so we'll end with a comparison of these two technologies, which will provide helpful context for those familiar with the Legacy Request Life Cycle. We have a lot to cover in this module, so let's get started in the next clip.
Working with Routing Routing is an essential component of the larger. NET core framework and is deeply integrated into MVC. In this module, our primary goal is to understand how routing works and why it is such a crucial part of the MVC Request Life Cycle. Although on the surface routing still behaves similar to past versions of MVC, the underlying implementation has changed quite a bit. Let's briefly revisit our high level Request Life Cycle diagram to ensure that we maintain proper context. So again, this module focuses exclusively on the routing stage, which can loosely be thought of as the second high level step in the Request Life Cycle. The most important concept of this module is that routing bridges middleware in the MVC framework by mapping incoming requests to controller action methods. Over the next several clips, we'll see just how that process works. So first we'll begin with a conceptual discussion of what routing is and how it works, specifically in the context of MVC. Then we'll be ready to look at some of these concepts in action with a simple routing demo. Once we're comfortable with the basics, we'll also start to explore the internal workings of routing. We'll see specifically what components are involved and how our URL is internally mapped to an action method behind the scenes. We'll then step through these concepts using the MVC source code. Finally, we'll discuss another type of routing called Attribute Routing, and examine some of the nuances of its behavior. We'll again illustrate these concepts using a simple demo. By the end of this module, you should have a strong understanding of how routing works, and just everything involved with actually mapping a request to a controller endpoint.
Understanding Controller Initialization and Execution In this module, let's now turn our focus to the controller initialization process in MVC. In the clips ahead, we will focus on how controllers are created and executed. Controllers are arguably the most important component in an MVC application, so understanding how they work provides all kinds of valuable insights into the framework. This topic integrates tightly with action method execution, which is the focus of the next module, but we'll just take things one step at a time and break them down into logical stages. So once again, let's revisit our high level diagram of the MVC Request Life Cycle. So far, we have covered middleware and routing, so this module will focus on the next conceptual stage in the pipeline. Controller creation is where we really start to get into the core of the MVC framework, rather than broader. NET core concepts like middleware. The rest of this course deals more with the components you'll use day to day in MVC, so there is a lot of value in understanding how they work. So first we'll begin with a high level discussion of controllers as they relate to the MVC Request Life Cycle. There is a lot that goes on behind the scenes to provide us with easy to use controllers, so we'll start to dissect those pieces in detail. We'll walk through the process of how a controller is selected to handle an incoming request, and see how this is actually driven by the available action methods. These components are one of many MVC extension points, so we'll see how to build custom constraints to gain even more control over the selection process. Once we understand how the controller and action method are selected, we'll discuss how that decision gets translated into an actual controller instance. This will include an analysis of important components like the controller factory and activator. Let's get started by reviewing some important controller concepts, and how they relate to the MVC Request Life Cycle.
Exploring Action Results and the View Engine In this module, let's explore Action Result execution, which is the final conceptual stage of the MVC Request Life Cycle. Everything we have studied up to this point is only relevant if we can actually generate a response to the client, and that's what Action Results are for. Let's revisit our high level Life Cycle diagram one final time to provide context for this module. As you can see here, Result Execution is the last stage of this pipeline. Action Results all follow similar patterns for writing a response out for the request, but conceptually we're going to split this process into two paths. First, we'll look at the more data-driven responses like JSON results, and then we'll see how the Razor View Engine is utilized to render out full HTML pages. We'll begin the module by reviewing what Action Results are, and how they integrate into the Request Life Cycle. Result Filters are a crucial part of this process, so we'll look at a demo of how they provide us with another opportunity to inject custom logic. We'll then move onto the Execution of the Action Result object itself, and see how this finally writes out a response for the incoming request. Content Negotiation is another important feature that can impact the rendered Action Result response. We'll explore some different options and scenarios for working with response data formatting. Views provide perhaps the most powerful and complex response rendering process in MVC. We'll explore the components involved and how they work together to provide templated HTML responses. We'll also see how dynamic Razor code gets translated into the final response body that gets sent back to the client. Working with Action Results in MVC is really interesting because we finally get to see how the collective application infrastructure generates a response. Let's start to dive into how all of this works in the next clip.