From b3cb36adf1b288ce386a45f9c1f53cb3d22f747c Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 17 May 2023 15:24:24 -1000 Subject: [PATCH 1/4] Problem details program.cs /5 --- aspnetcore/fundamentals/error-handling.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/aspnetcore/fundamentals/error-handling.md b/aspnetcore/fundamentals/error-handling.md index c4cdf830797e..1d9bf643fa3c 100644 --- a/aspnetcore/fundamentals/error-handling.md +++ b/aspnetcore/fundamentals/error-handling.md @@ -274,9 +274,8 @@ An implementation can be ***Note:*** When using a custom `IProblemDetailsWriter`, the custom `IProblemDetailsWriter` must be registered before calling , , or . - +:::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/middleware/problem-details-service/Program.cs" id="snippet_sampleproblemdetailswriter" ::: + #### Problem details from Middleware An alternative approach to using with is to set the in middleware. A problem details response can be written by calling [`IProblemDetailsService.WriteAsync`](/dotnet/api/microsoft.aspnetcore.http.iproblemdetailsservice.writeasync?view=aspnetcore-7.0&preserve-view=true): From cba1b40364b5269f381824c5380eb6264ccf615a Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 17 May 2023 15:29:16 -1000 Subject: [PATCH 2/4] Problem details program.cs /5 --- aspnetcore/fundamentals/error-handling.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/aspnetcore/fundamentals/error-handling.md b/aspnetcore/fundamentals/error-handling.md index 1d9bf643fa3c..99401cd61ec8 100644 --- a/aspnetcore/fundamentals/error-handling.md +++ b/aspnetcore/fundamentals/error-handling.md @@ -274,6 +274,8 @@ An implementation can be ***Note:*** When using a custom `IProblemDetailsWriter`, the custom `IProblemDetailsWriter` must be registered before calling , , or . +The following code adds the `SampleProblemDetailsWriter` to the DI container. Note that the custom `IProblemDetailsWriter` must be registered before calling `AddProblemDetails`: + :::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/middleware/problem-details-service/Program.cs" id="snippet_sampleproblemdetailswriter" ::: #### Problem details from Middleware From c8af6492f79649bb0c9859222ece4baa9e048aa9 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 17 May 2023 15:31:25 -1000 Subject: [PATCH 3/4] Problem details program.cs /5 --- aspnetcore/fundamentals/error-handling.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aspnetcore/fundamentals/error-handling.md b/aspnetcore/fundamentals/error-handling.md index 99401cd61ec8..d4e0aa2bae68 100644 --- a/aspnetcore/fundamentals/error-handling.md +++ b/aspnetcore/fundamentals/error-handling.md @@ -274,7 +274,7 @@ An implementation can be ***Note:*** When using a custom `IProblemDetailsWriter`, the custom `IProblemDetailsWriter` must be registered before calling , , or . -The following code adds the `SampleProblemDetailsWriter` to the DI container. Note that the custom `IProblemDetailsWriter` must be registered before calling `AddProblemDetails`: +The following code adds the `SampleProblemDetailsWriter` to the DI container: :::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/middleware/problem-details-service/Program.cs" id="snippet_sampleproblemdetailswriter" ::: From 02205ba6f3a3b3cb3da7066b4f2b98d102a45bff Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Wed, 17 May 2023 15:32:41 -1000 Subject: [PATCH 4/4] Problem details program.cs /5 --- aspnetcore/fundamentals/error-handling.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/aspnetcore/fundamentals/error-handling.md b/aspnetcore/fundamentals/error-handling.md index d4e0aa2bae68..6f3621523f69 100644 --- a/aspnetcore/fundamentals/error-handling.md +++ b/aspnetcore/fundamentals/error-handling.md @@ -272,9 +272,7 @@ An implementation can be :::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/middleware/problem-details-service/SampleProblemDetailsWriter.cs" ::: -***Note:*** When using a custom `IProblemDetailsWriter`, the custom `IProblemDetailsWriter` must be registered before calling , , or . - -The following code adds the `SampleProblemDetailsWriter` to the DI container: +***Note:*** When using a custom `IProblemDetailsWriter`, the custom `IProblemDetailsWriter` must be registered before calling , , or : :::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/middleware/problem-details-service/Program.cs" id="snippet_sampleproblemdetailswriter" :::