This is an ISAPI filter for transparent rewriting of URIs. It is useful for the common situation where you wish to retrieve a file from the database and the browser will not display it correctly unless it has the correct extension. It can also provide the browser with the appropriate name for use in saving to disk.
Note that there is a standard method for doing this without altering the URI (the Content-Disposition: header; see RFC2616 for more details. However, this is not respected by older browsers so providing both the Content-Disposition: header and a valid looking path can be beneficial.
To build from source, you will need to check out the project and related libraries from CVS. See the home page for instructions on CVS, and below for specific build instructions.
The component reads from the registry key HKLM\SOFTWARE\NPSL\RedirectFilter. The name of each value is the leading part of the URL to map; the actual data is the URL to map to. For example:
Name Data /files/ /download/download.asp
When a URL is matched, the name of the original request along with any parameters are passed on. In practical use, you would specify a link like <a href=”/files/somepdf.pdf?dbid=100″/>. This would be rewritten by the filter to /download/download.asp?page=%2Ffiles%2Fsomepdf.pdf&dbid=100. The ASP page (if used in this situation) would probably look something like:
rs = executeDBQuery Response.AddHeader "Content-Disposition: attachment; " & _ "filename="filename.pdf" Response.ContentType = "application/pdf" ' ensure no white space has been written Response.Clear Response.BinaryWrite rs("binary_field").Value, _ rs("binary_field").ActualSize ' ensure no white space follows Response.End
Additional redirects can be added with no maximum, but large numbers of rewrites will take a long time to match. Typically this is not necessary as most requests will be rewritten to a small number of pages; the handling being in the query string. (I have not found that query strings prevent older browers from determining the file type by extension).