Error handling for ASP.NET Core APIs — exception middleware, ProblemDetails,
94
90%
Does it follow best practices?
Impact
100%
1.13xAverage score across 5 eval scenarios
Passed
No known issues
A logistics company operates an internal ASP.NET Core API gateway used by warehouse management software and mobile delivery apps. The API already has a global exception handler that returns structured JSON error responses whenever an exception is thrown inside a controller.
However, the mobile team has reported two classes of problems that the exception handler does not cover:
/api/v1/shipmments/123 (double 'm'), the server returns a raw HTML 404 page from ASP.NET Core's routing layer rather than a structured JSON response. The mobile app cannot parse this and shows a blank screen.GET /api/shipments instead of POST /api/shipments/search, it gets a 405 Method Not Allowed response in plain text, again unparseable.The backend team has been asked to ensure that all non-200 HTTP responses — including routing misses and method mismatches that never reach a controller — return a consistent, machine-readable format with the appropriate Content-Type.
Produce the following files in your working directory:
Program.cs — the complete middleware pipeline configuration that addresses both problem classes, alongside a sample controller registrationpipeline_notes.md — a short explanation (3–5 sentences) of what middleware was added, what categories of errors it handles that the exception handler alone does not, and where in the pipeline it is placedThe Program.cs should demonstrate the correct ordering of all relevant middleware components. You do not need to implement controller logic — a stub MapControllers() call is sufficient.
evals
scenario-1
scenario-2
scenario-3
scenario-4
scenario-5
skills
aspnet-error-handling
verifiers