Global Middleware for Exception
Use custom middleware to catch and handle unhandled exceptions
-
Register middleware early in the pipeline (before routing)
-
Log exceptions and return a consistent error response (e.g., ProblemDetails format)
Example:
Register in Program.cs
:
No comments:
Post a Comment