An Example Native Module

For this tutorial, consider a requirement to prevent cross-linking of content on your website from some other website. A typical situation in which this might be useful is where your website contains some graphical content that some other website includes in its own web pages. Every time someone views the other web page, it causes a hit on your own web server, wasting valuable bandwidth and system resources.

Note
As usual, MSDN is your best friend when it comes to an authoritative and up-to-date reference. For a complete reference to the Native Code Module development API, refer to http://msdn2.microsoft.com/en-us/library/ms692081.aspx or http://learn.iis.net/page.aspx/112/iis-70-on-server-core/. At the time of this writing, there are no specific IIS 8 references.

Native Module Design

Note that it is assumed that you are familiar with CGI variables and how to use them to examine certain properties of a web request. In this tutorial, you will use the following CGI variables:

  • HTTP_REFERER—Contains the URI of the website where the request was initiated. A blank value may indicate that the request was initiated from a bookmark or manual entry, or possibly a search engine robot, and the like. A request that was initiated as a result of following a link on a web page (whether a internal reference such as an image link or actual user click on an href link) will contain the fully qualified URI of the originating web page (if any)—for example, http://www.Site1.com/path/file.html ...

Get Professional Microsoft IIS 8 now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.