I’m trying to understand what an HttpHandler is and what a HttpModule is and when I know that I must use one or the other of them. Please can you shed some light on this for me.
Thanks,
Sachin
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Handlers are for responding to specific types of requests (e.g. you might write one for .png files to serve dynamic images)
Modules are for manipulating the pipeline for potentially any type of request (e.g. you might use one to add, geo data to the
HttpContextbased on the request IP so that the code doesn’t need to. Although in practise they tend to be more complex than that)That said, with the advent of technologies such as Asp.Net MVC it’s possible to implement both sets of functionality as first-class features of your website’s code.
Cross-cutting concerns such as authentication etc (typically implemented with modules before) can now be done with Action Filters in MVC. And handling dynamic file types can be done with some clever routing. I’ve done the latter, for example, to implement dynamic content overriding of css/js and images using a database back-end.