Blog
Mert Özen's blog posts on software development, backend, frontend, and DevOps.
Chain of Responsibility: ASP.NET Core Middleware, DelegatingHandler and Validation Chains
Chain of Responsibility passes a request along a chain of handlers until one handles it, breaking the coupling between sender and receiver; ASP.NET Core middleware and DelegatingHandler are short-circuiting forms of the pattern. A discount approval chain in Bookstore, the hidden business rule carried by IEnumerable registration order in DI, a validation chain that stops at the first error versus a pipeline that collects everything, and the trap of a request falling off the end of the chain.
Global Error Handling in ASP.NET Core: Exception Middleware and ProblemDetails
Starting from the real response of an unhandled exception on .NET 6, we move to UseExceptionHandler with an error controller, then to our own middleware that maps domain exceptions to 404/409/500 ProblemDetails.
The ASP.NET Core Middleware Pipeline: Ordering, Use, Run, Map and Your Own Middleware
We follow a request through the middleware rings and the response back out: Use, Run and Map, writing middleware as a class, the effect of ordering, the recommended order of built-in middleware and typical pitfalls.