Book 92

This Wrox Blox provides a look into how to build and use custom ASP.NET httpHandlers to easily make advanced ASP.NET web sites. Learn fundamental concepts on what custom handlers are and how to use them. This Wrox Blox provides the opportunity to examine several real-world examples of custom httpHandlers to see how they can be applied and how they are developed. The author starts by covering built-in httpHandlers and adding an httpHandler to an ASP.NET Website. Next, the author discusses registering httpHandlers, and then basic, synchronous and asynchronous handlers, and a simple HTML handler. In addition, RSS, vCard, PDF, image resizer and recropper handlers are covered.

Table of Contents:

Built-in httpHandlers 2

Adding an httpHandler to an ASP.NET Web Site 2

How to Add a Custom Handler Class 3

Adding a Generic Handler File 3

Registering httpHandlers 4

Mapping File Extensions to ASP.NET 5

A Basic HTML Handler 9

Synchronous httpHandlers 11

Asynchronous httpHandlers 11

A Simple HTML Handler 12

RSS Handler 12

A vCard Handler 16

Image Resizer and Cropper Handlers 20

A PDF Handler 28

Publish a Stock Quote 34

Return a Compressed Document 38

Summary 45

About Chris Love 46


Book 94

This Wrox Blox explains how to create different types of custom modules for ASP.NET web sites. Custom ASP.NET Modules are a great way to program advanced features to your web site. This Wrox blox discusses the difference between a custom httpModule and the Global.asax file. It also covers the steps in the ASP.NET pipeline. The examples include using a custom module to configure a site's initial settings, a background worker thread, and an IP blocker. Other examples show how to add content to the content being sent to the client, URL Rewriting, and a custom error handler.

Table of Contents

Introduction to httpModules 1

How httpModules Are Processed 2

Modules versus Global.asax 3

A Minimal Custom httpModule 3

ASP.NET Page Life Cycle 5

Registering a Custom httpModule 7

Default httpModules 7

Remove Registered Modules 8

Use a Custom Module to Configure the Site 9

Creating a Background Thread Process 11

Modify Rendered Content 13

Optimizing the Response Output 16

Create an IP Filter 22

Rewrite a Request 25

A Custom Error Handler 28

Custom Modules in IIS 7 32

Summary 35

About Chris Love 36