Summary
HttpHandlers and HttpModules provide two ways to process requests and responses by extending the typical page framework. An HttpHandler targets specific kinds of files or requests that conform to certain file paths in the URL, whereas an HttpModule is intended to be first in line to process a request and last to process a response.HttpHandlers are classes that implement the IHttpHandler interface. They get a reference to the current HttpContext object in the ProcessRequest() method and can execute code against all of the HttpContext's properties. Typically, the HttpHandler analyzes the data that comes in from the Request and then sends something back via the Response object. HttpHandlers also implement an IsReusable property, telling ASP.NET whether the same instance of the class can be used to process subsequent requests.HttpModules enable code to interact with the application by adding event handlers to its events. These classes must implement the IHttpModule interface. The Init() method gives us a reference to the application, at which point we can wire up event handlers to the application's events. The event handlers can then interact with the application by implementing the standard event handler signature. The HttpModule also implements a Dispose() method, which is used to perform any necessary cleanup work if the application ends.