Chapter 18
Custom Handlers
After completing this chapter, you will be able to
Recognize the role of custom handlers in ASP.NET
Write custom binary handlers
Write just-in-time compiled custom handlers
Let IIS and ASP.NET know about your custom handler
This chapter covers writing custom HTTP handlers. In Chapter 2 we saw the ASP.NET pipeline. Remember that the endpoint of all requests handled by ASP.NET is always an implementation of IHttpHandler.
ASP.NET includes several classes capable of handling requests in the most common ways. For example, the Page class handles requests by interpreting the query strings and returning meaningful UI-oriented HTML. The Service class interprets incoming query strings as method calls and processes them accordingly. So far, we've been focusing on a single handler—[[<img src="/books/3/89/1/html/2/images/shy.gif"/>]]System.Web.UI.Page. However, there are other times when it's appropriate to tweak the processing or even handle it in a completely different way. You may find yourself needing to handle a request in a way not already provided through the System.Web.UI.Page or the System.Web.Services.Service classes. What do you do then? ASP.NET supports custom HTTP handlers for just such occasions.