Chapter 17. HTTP Handlers

Introduction

An HTTP handler is a class that intercepts and handles requests for a resource of a given type on a web server. HTTP handlers are a key feature of ASP.NET. For instance, when you request an .aspx file, a built-in HTTP handler intercepts the request and takes charge of loading and executing the .aspx file. ASP.NET also provides built-in HTTP handlers for .asmx, .ascx, .cs, and .vb files, as well as other file types. The <httpHandlers> element of the machine.config file contains a list of the standard HTTP handlers configured for your web server.

It’s possible to extend the built-in handlers provided by ASP.NET or to write your own. A custom HTTP handler is useful when you want to handle requests by your application for a given resource on your own. For example, custom handlers are useful for returning binary data, such as the contents of an image file, or for handling the processing necessary to access a resource stored in a database. HTTP handlers also provide a good mechanism for building reusable assemblies for your web applications, such as a general purpose file download module able to handle requests for virtually any file type. Each of these ideas is illustrated in the recipes in this chapter.

HTTP handlers are similar to the ISAPI extensions used to implement classic ASP for IIS. But, whereas ISAPI extensions are difficult to implement and can only be implemented in C++, HTTP handlers are supported by ASP.NET and can be implemented in any .NET language.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset