The <filter> element of the <isapiFilters> collection configures an ISAPI filter to process client request data or server response data.
| |
IIS 7.0 |
IIS 6.0 |
| Notes |
The <filter> element of the <isapiFilters> collection is new in IIS 7.0. |
The <isapiFilters> collection replaces the IIS 6.0 FilterEnableCache and FilterPath metabase properties.
|
To use the <isapiFilters> element, you must install the ISAPI Filters module on your IIS 7.0 server. To do so, use the following steps.
Windows Server 2008
- On the taskbar, click Start, point to Administrative Tools, and then click Server Manager.
- In the Server Manager hierarchy pane, expand Roles, and then click Web Server (IIS).
- In the Web Server (IIS) pane, scroll to the Role Services section, and then click Add Role Services.
- On the Select Role Services page of the Add Role Services Wizard, select ISAPI Filters, and then click Next.
- On the Confirm Installation Selections page, click Install.
- On the Results page, click Close.
Windows Vista
- On the taskbar, click Start, and then click Control Panel.
- In Control Panel, click Programs and Features, and then click Turn Windows Features on or off.
- In the Windows Features dialog box, expand Internet Information Services, then World Wide Web Services, then Application Development Features.
- Select ISAPI Filters, and then click OK.
How to add an ISAPI filter
- On the taskbar, click Start, point to Administrative Tools, and then click Internet Information Services (IIS) Manager.
- In the Connections pane, go to the connection, site, application, or directory for which you want to configure page output caching.
- In the Home pane, double-click ISAPI Filters.
- In the Actions pane, click Add...
- In the Filter name text box of the Add ISAPI Filter dialog box, type a friendly name for the ISAPI filter.
- In the Executable box, type the file system path of the location of ISAPI filter file or click the ellipsis button (...) to navigate to the folder that contains the ISAPI filter file, and then click OK.
Attributes
| Attribute |
Description |
enableCache |
Optional Boolean attribute.
Specifies whether HTTP.sys caching is enabled (true) or disabled (false) for filtered server responses.
The default value is false. |
enabled |
Optional Boolean attribute.
Specifies whether the installed filter is enabled (true) or disabled (false).
The default value is true. |
name |
Required string attribute.
Specifies the unique name of the ISAPI filter. |
path |
Required string attribute.
Specifies the full physical path of the ISAPI filter .dll file. |
preCondition |
Optional string attribute.
Specifies conditions under which the ISAPI filter will run.
The preCondition attribute can be one or more of the following possible values. If you specify more than one value, separate the values with a comma (,).
| Value |
Description |
bitness32 |
Specify the bitness32 value when the ISAPI filter is a 32-bit .dll file and IIS should load the filter only for worker processes that run in WOW64 mode (32-bit simulation) on a 64-bit operating system. |
bitness64 |
Specify the bitness64 value when the ISAPI filter is a 64-bit .dll file and IIS should load the filter only for worker processes that run in 64-bit mode. |
integratedMode |
Specify the integratedMode value when the ISAPI filter should use the integrated request-processing pipeline to process requests for managed content. |
ISAPIMode |
Specify the ISAPIMode value when the ISAPI filter should use the ASP.NET ISAPI extension, Aspnet_isapi.dll, to process requests for managed content. |
runtimeVersionv1.1 |
Specify the runtimeVersionv1.1 value when the ISAPI filter should load only for application pools that are configured to use .NET Framework version 1.1. |
runtimeVersionv2.0 |
Specify the runtimeVersionv2.0 value when the ISAPI filter should load only for application pools that are configured to use .NET Framework version 2.0. |
|
Child Elements
None.
Configuration Sample
The following configuration example, when added to a Web.config file, adds an ISAPI filter named SalesQueryIsapi to a Web site or application. The sample names and enables the ISAPI filter with the name and enabled attributes. It also uses the enableCache attribute to disable HTTP.sys caching and the path attribute to specify the location of the ISAPI DLL.
<configuration>
<system.webServer>
<isapiFilters>
<filter
name="SalesFilter"
enabled="true"
enableCache="false"
path="C:\Inetpub\filters\SalesFilter.dll" />
</isapiFilters>
</system.webServer>
</configuration>
The following examples configure an ISAPI filter named SalesQueryIsapi on the server. Each of the examples use the name property to specify a name for the ISAPI filter, the enableCache property to disable HTTP.sys caching, and the path property to specify the location of the ISAPI DLL.
AppCmd.exe
appcmd.exe set config -section:system.webServer/isapiFilters /+"[name='SalesQueryIsapi',path='c:\Inetpub\www.contoso.com\filters\SalesQueryIsapi.dll',enabled='True',enableCache='True']" /commit:apphost
C#
using System;
using System.Text;
using Microsoft.Web.Administration;
internal static class Sample
{
private static void Main()
{
using (ServerManager serverManager = new ServerManager())
{
Configuration config = serverManager.GetApplicationHostConfiguration();
ConfigurationSection isapiFiltersSection = config.GetSection("system.webServer/isapiFilters");
ConfigurationElementCollection isapiFiltersCollection = isapiFiltersSection.GetCollection();
ConfigurationElement filterElement = isapiFiltersCollection.CreateElement("filter");
filterElement["name"] = @"SalesQueryIsapi";
filterElement["path"] = @"c:\Inetpub\www.contoso.com\filters\SalesQueryIsapi.dll";
filterElement["enabled"] = true;
filterElement["enableCache"] = true;
isapiFiltersCollection.Add(filterElement);
serverManager.CommitChanges();
}
}
}
VB.NET
Imports System
Imports System.Text
Imports Microsoft.Web.Administration
Module Sample
Sub Main()
Dim serverManager As ServerManager = New ServerManager
Dim config As Configuration = serverManager.GetApplicationHostConfiguration
Dim isapiFiltersSection As ConfigurationSection = config.GetSection("system.webServer/isapiFilters")
Dim isapiFiltersCollection As ConfigurationElementCollection = isapiFiltersSection.GetCollection
Dim filterElement As ConfigurationElement = isapiFiltersCollection.CreateElement("filter")
filterElement("name") = "SalesQueryIsapi"
filterElement("path") = "c:\Inetpub\www.contoso.com\filters\SalesQueryIsapi.dll"
filterElement("enabled") = True
filterElement("enableCache") = True
isapiFiltersCollection.Add(filterElement)
serverManager.CommitChanges()
End Sub
End Module
JavaScript
var adminManager = new ActiveXObject('Microsoft.ApplicationHost.WritableAdminManager');
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST";
var isapiFiltersSection = adminManager.GetAdminSection("system.webServer/isapiFilters", "MACHINE/WEBROOT/APPHOST");
var isapiFiltersCollection = isapiFiltersSection.Collection;
var filterElement = isapiFiltersCollection.CreateNewElement("filter");
filterElement.Properties.Item("name").Value = "SalesQueryIsapi";
filterElement.Properties.Item("path").Value = "c:\\Inetpub\\www.contoso.com\\filters\\SalesQueryIsapi.dll";
filterElement.Properties.Item("enabled").Value = true;
filterElement.Properties.Item("enableCache").Value = true;
isapiFiltersCollection.AddElement(filterElement);
adminManager.CommitChanges();
VBScript
Set adminManager = createObject("Microsoft.ApplicationHost.WritableAdminManager")
adminManager.CommitPath = "MACHINE/WEBROOT/APPHOST"
Set isapiFiltersSection = adminManager.GetAdminSection("system.webServer/isapiFilters", "MACHINE/WEBROOT/APPHOST")
Set isapiFiltersCollection = isapiFiltersSection.Collection
Set filterElement = isapiFiltersCollection.CreateNewElement("filter")
filterElement.Properties.Item("name").Value = "SalesQueryIsapi"
filterElement.Properties.Item("path").Value = "c:\\Inetpub\\www.contoso.com\\filters\\SalesQueryIsapi.dll"
filterElement.Properties.Item("enabled").Value = True
filterElement.Properties.Item("enableCache").Value = True
isapiFiltersCollection.AddElement filterElement
adminManager.CommitChanges()