From d20f5b56999053f3ebdb4917111bc2399ba38c42 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Tue, 9 May 2023 14:10:42 -1000 Subject: [PATCH 1/3] warn about registering customer service /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 fa92ce2c4d4e..363b625c1865 100644 --- a/aspnetcore/fundamentals/error-handling.md +++ b/aspnetcore/fundamentals/error-handling.md @@ -247,6 +247,8 @@ The automatic creation of a `ProblemDetails` can be customized using any of the 2. Use a custom [`IProblemDetailsWriter`](#custom-iproblemdetailswriter) 3. Call the [`IProblemDetailsService` in a middleware](#problem-details-from-middleware) +***Note:*** When using a custom `IProblemDetailsWriter`, the custom `IProblemDetailsWriter` must be registered before calling , , or . + #### `CustomizeProblemDetails` operation The generated problem details can be customized using , and the customizations are applied to all auto-generated problem details. From 60a062c210c8c256ca4169df594fbda88bf2d515 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Thu, 11 May 2023 15:55:35 -1000 Subject: [PATCH 2/3] prob det --- aspnetcore/fundamentals/error-handling.md | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/aspnetcore/fundamentals/error-handling.md b/aspnetcore/fundamentals/error-handling.md index 363b625c1865..86cadc1e849d 100644 --- a/aspnetcore/fundamentals/error-handling.md +++ b/aspnetcore/fundamentals/error-handling.md @@ -247,8 +247,6 @@ The automatic creation of a `ProblemDetails` can be customized using any of the 2. Use a custom [`IProblemDetailsWriter`](#custom-iproblemdetailswriter) 3. Call the [`IProblemDetailsService` in a middleware](#problem-details-from-middleware) -***Note:*** When using a custom `IProblemDetailsWriter`, the custom `IProblemDetailsWriter` must be registered before calling , , or . - #### `CustomizeProblemDetails` operation The generated problem details can be customized using , and the customizations are applied to all auto-generated problem details. @@ -270,7 +268,11 @@ For example, an [`HTTP Status 400 Bad Request`](https://developer.mozilla.org/do #### Custom `IProblemDetailsWriter` -An implementation can be created for advanced customizations: +An implementation can be created for advanced customizations. + +:::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 . :::code language="csharp" source="~/../AspNetCore.Docs.Samples/fundamentals/middleware/problem-details-service/SampleProblemDetailsWriter.cs" ::: From 74a8ff4f110e6a21a8b6d194ed1a8ef26ffba339 Mon Sep 17 00:00:00 2001 From: Rick Anderson <3605364+Rick-Anderson@users.noreply.github.com> Date: Thu, 11 May 2023 16:07:02 -1000 Subject: [PATCH 3/3] prob det --- aspnetcore/fundamentals/error-handling.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/aspnetcore/fundamentals/error-handling.md b/aspnetcore/fundamentals/error-handling.md index 86cadc1e849d..c4cdf830797e 100644 --- a/aspnetcore/fundamentals/error-handling.md +++ b/aspnetcore/fundamentals/error-handling.md @@ -274,8 +274,9 @@ 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/SampleProblemDetailsWriter.cs" ::: - + #### 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):