O'Reilly logo

Professional Microsoft IIS 8 by Benjamin Perkins, Dennis Glendenning, Scott Forsyth, Jeff Cochran, Kenneth Schaefer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

An Example Managed Module

If you have already completed the previous tutorial in this chapter and completed the development of a custom module using native code, then you will be familiar with the example functionality of the Cross Link Blocker. Otherwise, you should review the information on Module Design previously covered in this chapter.

Managed Module Design

As with the native module design, the BeginRequest event will be the notification used to implement this module. Also, the request information used will be the values of the SERVER_NAME and HTTP_REFERER variables provided by the CGI framework.

The example native code module used the RQ_NOTIFICATION_FINISH_REQUEST return code to interrupt the request processing when a cross-linked request was discovered. Although this might be a good way to reduce the performance and bandwidth hit that cross-link requests would otherwise create, it does not necessarily provide the most eloquent solution.

The following example delivers an alternative pre-defined image in place of the requested file. The replacement image may be very small, or blank, to minimize bandwidth overheads, or may carry some copyright or “access denied” text. This tutorial demonstrates use of a small text-carrying image, but you can use any file you like—even a nasty surprise for the cross-linker!

Managed Module Creation

Although the IDE used in this sample is Visual Studio 2012, you can use other IDE versions and products. You can even use a plaintext editor like ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required