Advertisement
Intermediate ASP.NET Core, Error Handling

What happens by default in ASP.NET Core if you don't configure any global exception handling middleware at all?

Short answer

Without any exception handling middleware configured, an unhandled exception propagates all the way up through Kestrel, resulting in either a bare 500 Internal Server Error with no body (in Production) or, if the developer exception page is active, a detailed HTML error page…

Save ASP.NET Core mock interview
Advertisement
AModel answer
Without any exception handling middleware configured, an unhandled exception propagates all the way up through Kestrel, resulting in either a bare 500 Internal Server Error with no body (in Production) or, if the developer exception page is active, a detailed HTML error page with the full stack trace -- neither is appropriate for a real production API, which is why configuring at least a basic UseExceptionHandler is considered essential baseline setup.
Example

// With NO exception handling middleware configured: // An unhandled exception results in a generic 500 with an empty or minimal body // -- no consistent JSON error format, no logging guarantee, no safe error message

Real-world example
A newly bootstrapped API prototype that skipped configuring UseExceptionHandler entirely is caught in code review before its first production deployment, since every unhandled exception would otherwise return an unhelpful bare 500 response.
Likely follow-ups
  • What's the minimum viable exception handling setup for a new ASP.NET Core API?
  • Why does Kestrel itself not provide a default JSON error format?
Related topics