Other day,at work, we were discussing about building a Business Interceptor. Idea is to build centralized component to intercept all web request and associate them to a Business component and pass it on to handler to do the further request processing. Approach something we inherited from Struts approach and FrontController kind of approach. Nice FrontController Article
So we had a discussion when to choose between Handler vs Module. This is my opinion, might be wrong. Before that, a quick briefing about module and handler.
Handler as it say handles request - which would mean take a request and return a response. Handler is the end point of the request chain. Module pipes the request - it can read the request, modify the request, but ultimately is not responsible for handling request but pipe that to another module or finally hand it over to handler. And importantly, the module is for every request whereas handler has other attributes affect like the extension, the verb we are looking.
Some of the decision we made is that we don't want any custom extension or different extension like ".ashx" though it is practice is java world. They for e.g. attach ".do" for struts environment.
With above understanding, the interceptor we are building is clearly a module. Every request will be intercepted and first will be validate to see if they have any special business logic mapped and will be handle appropriately and will be piped through other module and finally handed over to custom handler or asp default handler. And in case no business logic, just follows the standard pipeline and finally handed over to the handler.
In another scenario, we wrote an HTTPHandler to read image from db and write to response as binary. So in this case, it takes the parameters reads the BLOB from DB and write to response stream and request ends with a response back to the user.