Chain of Responsibility: Introduction

Get a brief introduction to the Chain of Responsibility design pattern.

The Chain of Responsibility design pattern allows us to apply multiple processing steps to action. Any process step can have a condition added to it, allowing it to exit the process immediately and not execute any further steps.

Perhaps the best-known example of the Chain of Responsibility design pattern in .NET is ASP.NET Core middleware. This is where we can apply multiple stages of processing to incoming HTTP requests. The request won’t get to its destination until it goes through all the steps, which we, as application developers, can add or remove at will. For example, we can add a step to verify whether the user is authorized. Then, if so, the request will proceed to the next processing stage. If not, the response will be returned immediately with an appropriate response code.

Get hands-on with 1400+ tech skills courses.