Developer Notes for ISAPI Filters

ISAPI filters provide you with a versatile tool for extending IIS functionality to meet your special requirements. There are some important issues you should consider in developing your filter. The following notes provide some general guidelines summarizing these issues.

You can add an ISAPI filter programmatically using the IIS Admin Objects. Filters can be added to either the WWW service or to an individual Web site. To add a filter you must first create an IIsFilters object. IIsFilters is a container object that you can populate with IIsFilter objects.

For example, the following script would add an IIsFilters object to the WWW service. Note that a Filters object is created for the WWW service when IIS is installed. For an individual Web site you may need to create this object before you can use it.

Dim FiltersObj
Dim LoadOrder

Set FiltersObj = GetObject("IIS://LocalHost/W3SVC/Filters")
LoadOrder = FiltersObj.FilterLoadOrder
If LoadOrder = "" Then
    LoadOrder = LoadOrder & ","
End If
LoadOrder = LoadOrder & "myFilter"
FiltersObj.FilterLoadOrder = LoadOrder
FiltersObj.SetInfo
 

Once you have established the IIsFilters container object, you can add your IIsFilter object and set its properties.

For example, the following script adds a new IIsFilter, myFilter, and sets the path and description.

Dim FilterObj
Dim FilterName

FilterName = "myFilter"
FilterPath = "C:\iisfilts\myfilter.dll"
FilterDesc = "This is my filter"

Set FilterObj = FiltersObj.Create("IIsFilter", FilterName)
FilterObj.FilterPath = FilterPath
FilterObj.FilterDescription = FilterDesc
FilterObj.SetInfo
 

For a working example of an administrative script that adds a filter, see Additional Admin Script Examples in the Developer Samples. For more information on the Admin Objects see IIS Admin Objects.


© 1997 by Microsoft Corporation. All rights reserved.