AspNetCore.Docs/aspnetcore/includes/problem-details-service.md

1.7 KiB

Problem Details are not the only response format to describe an HTTP API error, however, they are commonly used to report errors for HTTP APIs.

The problem details service implements the xref:Microsoft.AspNetCore.Http.IProblemDetailsService interface, which supports creating problem details in ASP.NET Core. The AddProblemDetails extension method on xref:Microsoft.Extensions.DependencyInjection.IServiceCollection registers the default IProblemDetailsService implementation.

In ASP.NET Core apps, the following middleware generates problem details HTTP responses when AddProblemDetails is called, except when the Accept request HTTP header doesn't include one of the content types supported by the registered xref:Microsoft.AspNetCore.Http.IProblemDetailsWriter (default: application/json):