forked from dodyg/practical-aspnetcore
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
111 additions
and
121 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
# Middleware (12) | ||
|
||
We will explore all aspect of middleware building in this section. | ||
|
||
* [Middleware 1](/projects/middleware/middleware-1) | ||
|
||
This example shows how to pass information from one middleware to another using `HttpContext.Items`. | ||
|
||
* [Middleware 2](/projects/middleware/middleware-2) | ||
|
||
As a general rule, only one of your Middleware should write to Response in an execution path. This sample shows how to work around this by buffering the Response. | ||
|
||
e.g. | ||
|
||
If path `/` involves the execution of Middleware 1, Middleware 2 and Middleware 3, only one of these should write to Response. | ||
|
||
* [Middleware 3](/projects/middleware/middleware-3) | ||
|
||
This is the simplest middleware class you can create. | ||
|
||
* [Middleware 4](/projects/middleware/middleware-4) | ||
|
||
Use `app.Map` (`MapMiddleware`) to configure your middleware pipeline to respond only on specific url path. | ||
|
||
* [Middleware 5](/projects/middleware/middleware-5) | ||
|
||
Nested `app.Map` (show `Request.Path` and `Request.PathBase`). | ||
|
||
* [Middleware 6](/projects/middleware/middleware-6) | ||
|
||
Use `app.MapWhen`(`MapWhenMiddleware`) and Nested `app.Map` (show `Request.Path` and `Request.PathBase`). | ||
|
||
* [Middleware 7](/projects/middleware/middleware-7) | ||
|
||
Use `MapMiddleware` and `MapWhenMiddleware` directly without using extensions (show `Request.Path` and `Request.PathBase`). | ||
|
||
* [Middleware 8](/projects/middleware/middleware-8) | ||
|
||
Demonstrate the various ways you can inject dependency to your middleware class *manually*. | ||
|
||
* [Middleware 9](/projects/middleware/middleware-9) | ||
|
||
Demonstrate how to ASP.NET Core built in DI (Dependency Injection) mechanism to provide dependency for your middleware. | ||
|
||
* [Middleware 10](/projects/middleware/middleware-10) | ||
|
||
Demonstrate that a middleware is a singleton. | ||
|
||
* [Middleware 11](/projects/middleware/middleware-11) | ||
|
||
This sample is similar to `Middleware 10` except that this one implement `IMiddleware` to create Factory-based middleware activation. This means that you can create a middleware that is not a singleton (either Transient or Scoped). | ||
|
||
* [Middleware 12](/projects/middleware/middleware-12) | ||
|
||
Contrast the usage of `MapWhen` (which branch execution) and `UseWhen` (which doesn't branch execution) in configuring your Middleware. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
projects/razor-pages/razor-pages-mvc/Controllers/EntryController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
projects/razor-pages/razor-pages-mvc/Pages/RazorPages/Create.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
projects/razor-pages/razor-pages-mvc/Pages/RazorPages/Create.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
projects/razor-pages/razor-pages-mvc/Pages/RazorPages/Edit.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
projects/razor-pages/razor-pages-mvc/Pages/RazorPages/Index.cshtml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
projects/razor-pages/razor-pages-mvc/Pages/RazorPages/Index.cshtml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,9 @@ | ||
<Project Sdk="Microsoft.NET.Sdk.Web"> | ||
<PropertyGroup> | ||
<TargetFramework>netcoreapp3.1</TargetFramework> | ||
<RootNamespace>RazorPagesMvc</RootNamespace> | ||
<AssemblyName>RazorPagesMvc</AssemblyName> | ||
</PropertyGroup> | ||
|
||
|
||
<ItemGroup> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="3.1.2" /> | ||
<PackageReference Include="Microsoft.EntityFrameworkCore.InMemory" Version="3.1.2" /> | ||
</ItemGroup> | ||
</Project> |