Skip to content

Commit 93f1d03

Browse files
Copilotwadepickett
andauthored
docs: Add DefaultProblemDetailsWriter supported media types; fix typo (#36836)
* Initial plan * Add supported media types info for DefaultProblemDetailsWriter; fix typo Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com> * Update media types supported by DefaultProblemDetailsWriter Clarified supported media types for DefaultProblemDetailsWriter. Formatted it so it would be easier to read. --------- Co-authored-by: copilot-swe-agent[bot] <198982749+Copilot@users.noreply.github.com> Co-authored-by: wadepickett <10985336+wadepickett@users.noreply.github.com> Co-authored-by: Wade Pickett <wpickett@microsoft.com>
1 parent 536ac29 commit 93f1d03

1 file changed

Lines changed: 12 additions & 3 deletions

File tree

aspnetcore/fundamentals/error-handling-api.md

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ description: Learn about error handling in ASP.NET Core APIs with Minimal APIs a
55
ai-usage: ai-assisted
66
ms.author: wpickett
77
monikerRange: '>= aspnetcore-7.0'
8-
ms.date: 08/15/2025
8+
ms.date: 03/04/2026
99
uid: fundamentals/error-handling-api
1010
---
1111

@@ -139,9 +139,18 @@ In the following code, `httpContext.Response.WriteAsync("Fallback: An error occu
139139
140140
The preceding code:
141141
142-
* Writes an error message with the fallback code if the `problemDetailsService` is unable to write a `ProblemDetails`. For example, an endpoint where the [Accept request header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Accept) specifies a media type that the `DefaulProblemDetailsWriter` does not support.
142+
* Writes an error message with the fallback code if the `problemDetailsService` is unable to write a `ProblemDetails`. For example, an endpoint where the [Accept request header](https://developer.mozilla.org/docs/Web/HTTP/Headers/Accept) specifies a media type that the `DefaultProblemDetailsWriter` does not support.
143143
* Uses the [Exception Handler Middleware](#exception-handler).
144144
145+
> [!NOTE]
146+
> The `DefaultProblemDetailsWriter` supports the following media types in the `Accept` request header:
147+
>
148+
> * `application/json`
149+
> * `application/problem+json`
150+
> * Wildcard types such as `*/*` and `application/*`
151+
>
152+
> Non-JSON media types, such as `application/xml` or `text/html`, are **not** supported and trigger the fallback behavior.
153+
145154
The following sample is similar to the preceding except that it calls the [`Status Code Pages middleware`](#client-and-server-error-responses).
146155
147156
:::code language="csharp" source="~/fundamentals/minimal-apis/handle-errors/sample8/Program.cs" id="snippet_IProblemDetailsServiceWithStatusCodePageFallback" highlight="15":::
@@ -255,4 +264,4 @@ The contents of the response can be modified from outside of the controller usin
255264
256265
* [How to Use ModelState Validation in ASP.NET Core Web API](https://code-maze.com/aspnetcore-modelstate-validation-web-api/)
257266
* [View or download sample code](https://github.com/dotnet/AspNetCore.Docs.Samples/tree/main/fundamentals/middleware/problem-details-service)
258-
* [Hellang.Middleware.ProblemDetails](https://www.nuget.org/packages/Hellang.Middleware.ProblemDetails/)
267+
* [Hellang.Middleware.ProblemDetails](https://www.nuget.org/packages/Hellang.Middleware.ProblemDetails/)

0 commit comments

Comments
 (0)