From the course: ASP.NET Core: Middleware
Unlock this course with a free trial
Join today to access over 25,300 courses taught by industry experts.
Solution: Implement a middleware - ASP.NET Core Tutorial
From the course: ASP.NET Core: Middleware
Solution: Implement a middleware
(upbeat music) - [Instructor] Welcome back. As always, there's more than one way of doing things, so if you've come to a different solution, that is perfectly fine. Mine is just a suggestion. Usually when you have something like an A/B test, you just have different content on the server, and then the application would then either use one view or the other. That works especially well when using MVC, but of course can also be achieved with Razor Pages or in a Blazor application. I'd like to use a middleware though, and I will be using a redirect, and you'll see the effect of that. Here's how this can be achieved. All right, before we start, let me get rid of some of the middlewares we already have in there. We now need to do two things. We need to find out whether we were actually trying to retrieve that index Razor page, and if so, we might redirect to the new version so we can do the A/B test. Here's how that could look like. So we start once again with app.Use, receiving at context…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
The ASP.NET Core pipeline6m 9s
-
(Locked)
Built-in ASP.NET Core middlewares5m 54s
-
(Locked)
Creating a middleware with Run()2m 25s
-
(Locked)
Creating a middleware with Use()5m 9s
-
(Locked)
Route-specific middlewares with Map()2m 34s
-
(Locked)
Middlewares with MapWhen() and UseWhen()6m 58s
-
(Locked)
Challenge: Implement a middleware1m 38s
-
(Locked)
Solution: Implement a middleware8m 45s
-
-
-