Chain of responsibility pattern in ASP.net
The chain of responsibility pattern is a design pattern consisting of a series of processing objects through which we pass a data stream for filtration or modification. Ultimately, the process terminates when the data stream passes the last processing object at the end of the chain. The ASP.NET pipeline is a wonderful example where the chain of responsibility pattern is leveraged to provide an extensible programming model. The ASP.NET infrastructure implements WebForms API, ASMX Web services, WCF, ASP.NET Web API, and ASP.NET MVC using HTTP modules and handlers. Every request in the pipeline passes through a series of modules (a class that implements IHttpModule
) before it reaches its target handler (a class that implements IHttpHandler
). Once a module in the pipeline has done its duty, it passes the responsibility of the request processing to the next module in the chain. Finally, it reaches the handler. The following code snippet shows how one...