ISAPIFilter Sample: Maps URLs to Parameterized Queries
This documentation is archived and is not being maintained.

ISAPIFilter Sample: Maps URLs to Parameterized Queries 

Download sample

Demonstrates the creation of an ISAPI filter using ATL Server's support classes. The filter maps URL requests to new addresses using regular expression replacements provided in a configuration file.

ATL Server does not provide direct support for ISAPI filters; it only provides support for ISAPI extensions. There are many utility classes provided by ATL and ATL Server that make building a site-enhancing filter easier.

This sample is a name-mapping filter that translates one URL into another using regular expressions. The mappings are read from a file named friendly.cfg that must be in the same directory as the filter DLL. Each pair of lines is a regular expression to match against followed by a replacement to use if the regular expression is matched. Blank lines are ignored. The regular expressions are checked in the order that they appear in the file.

NoteNote

The configuration file is loaded once when the filter is first loaded. Subsequent changes to the configuration file will not be apparent in the filter until it is reloaded.

The configuration file provided with this example includes a single replacement that maps URLs of the form /hello/{\a*} to the following URL: /isapifilter/hello.dll?user=$0. This causes the part of the path following /hello/ to be passed to the request handler DLL in the query string.

Security noteSecurity Note

This sample code is provided to illustrate a concept and should not be used in applications or Web sites, as it may not illustrate the safest coding practices. Microsoft assumes no liability for incidental or consequential damages should the sample code be used for purposes other than as intended.

Building and Running the Sample

To build and run this sample

  1. Open the solution file, IsapiFilter.sln, in the Visual Studio development environment.

  2. Build the solution. This will also deploy the solution to the local Web server.

  3. Open Internet Services Manager. Click the Start button, point to Programs, point to Administrative Tools, and click Internet Services Manager.

  4. Right-click the active Web site for port 80 (typically Default Web Site) and click Properties from the shortcut menu.

  5. Click the ISAPI Filters property page and add \INetpub\wwwroot\ISAPIFilter\friendly.dll to the list of installed filters. Click OK to close the dialog box.

    NoteNote

    This adds friendly.dll from the location where it is deployed.

  6. Use a Web browser to view http://localhost/hello/YourName (replace YourName with your name). You should see a message greeting you. Observe that your Web site does not have a document or directory that corresponds to the URL you entered, so you can be sure that the filter has redirected the request to the request handler DLL.

Demonstrates

See Also

Other Resources

ATL Server Samples

Show:
© 2016 Microsoft