Problem Details Demo
Web API endpoints
Use Swagger UI to explore various Problem detail responses from Web API endpoints
TryMore information
- rfc7807 - official Problem Details spec
- Source code for this demo
- Hellang.Middleware.ProblemDetails Nuget library
- Blog post demonstrating nuget library
MVC HTML endpoints
Confirm that exceptions / non-success status codes from HTML endpoints are NOT sent as Problem details responses
TryServing both HTML and JSON responses?
If yes, you will need to configure different exception handling middleware for each response type.
app.UseWhen(IsUIRequest, app2 =>
{
app2.UseExceptionHandler("/ui/home/error");
app2.UseStatusCodePages();
});
app.UseWhen(IsNonUIRequest, app2 =>
{
app2.UseProblemDetails();
});