AspNetCore.Docs icon indicating copy to clipboard operation
AspNetCore.Docs copied to clipboard

[ProblemDetailsService] Add Information about what MediaTypes are not supported to help deciding when to use which

Open DevTKSS opened this issue 2 months ago • 2 comments

Description

The preceding code:

  • 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 specifies a media type that the DefaulProblemDetailsWriter does not support.

I miss a link or Note with which Media Types I would need to use the second sample on this page, that is not supported by the default DefaultProblemDetailsWriter you are reffering to. The API Reference does not list those unsupported ones either

Page URL

https://learn.microsoft.com/en-us/aspnet/core/fundamentals/error-handling-api?view=aspnetcore-10.0&tabs=minimal-apis#problem-details

Content source URL

https://github.com/dotnet/AspNetCore.Docs/blob/main/aspnetcore/fundamentals/error-handling-api.md

Document ID

5ad65468-c51c-9899-c435-6e99d734d0b8

Platform Id

bc49b255-ac35-3229-e350-58e76d52238c

Article author

@brunolins16

Metadata

  • ID: 5ad65468-c51c-9899-c435-6e99d734d0b8
  • PlatformId: bc49b255-ac35-3229-e350-58e76d52238c
  • Service: aspnet-core
  • Sub-service: fundamentals

DevTKSS avatar Dec 10 '25 13:12 DevTKSS

AI Analysis Report

GitHub Copilot Analysis test, by by: @wadepickett Date: 2025-12-10 Issue: 36477 Model: GitHub Copilot


Issue Analysis: Add Information about Supported/Unsupported Media Types for DefaultProblemDetailsWriter

✅ Issue Validation

Status: Valid and actionable

📋 Issue Summary

The issue reporter correctly identifies that the documentation mentions a fallback scenario when the DefaultProblemDetailsWriter is unable to write a ProblemDetails response due to unsupported media types in the Accept header, but fails to specify which media types are actually supported. This is a documentation gap that leaves readers without the information needed to understand when the fallback code would be triggered.

Based on investigation of the ASP. NET Core source code, the DefaultProblemDetailsWriter supports:

  • application/json
  • application/problem+json
  • Wildcard types like */* and application/*

Media types like application/xml, text/html, or other non-JSON types are not supported.

📁 Affected Files

File Path Lines Section
Main article [aspnetcore/fundamentals/error-handling-api. md](https://github.com/dotnet/AspNetCore. Docs/blob/ea0370758dbda81a21e9c1216a9c6ae3fc51424a/aspnetcore/fundamentals/error-handling-api.md#L140-L143) 140-143 "IProblemDetailsService fallback"
Include file [aspnetcore/includes/problem-details-service.md](https://github.com/dotnet/AspNetCore.Docs/blob/ea0370758dbda81a21e9c1216a9c6ae3fc51424a/aspnetcore/includes/problem-details-service. md#L5) 5 Problem details middleware description

📝 Proposed Changes

Documentation Updates

File: aspnetcore/fundamentals/error-handling-api.md Location: Lines 140-143 (after the bullet point about the Accept request header) Type: New NOTE block

Current content (lines 140-143):

The preceding code: 

* 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.
* Uses the [Exception Handler Middleware](#exception-handler).

wadepickett avatar Dec 10 '25 18:12 wadepickett

Thanks @DevTKSS for pointing this out!

wadepickett avatar Dec 10 '25 19:12 wadepickett