I've used a couple of methods to initiate a logon requirement for arbitrary files.
One was custom 404 error pages. I remove the file from the virtual www-accessible file-system. Then when someone hits the document, it goes to the 404 error page. From there I parse the REQUEST_URI field, check authentication, do custom logging, retrieve the file and output it. All with a 200 response code, so as not to confuse the browser.
Another method I've used is building my own database-driven virtual file system, but this method does rely on a particular server enviornment, since I use PHP and Apache, it uses the Apache mod_rewrite module. I'm not sure what would be the ASP/IIs equivalent of this.
Here's a write-up I did on the mod_rewrite method though, which might help you start looking for a way to do it with .NET and IIs:
http://p2p.wrox.com/topic.asp?TOPIC_ID=31036
This latter method is very similar to the 404 method, except I am not relying on the 404 error script to do the work. Also, if you read my post there you'll see that the 404 method can be buggy. Essentially what happens is I can create "clean-URIs". That is to say instead of:
http://p2p.wrox.com/topic.asp?TOPIC_ID=31036
I can create:
http://p2p.wrox.com/topic/31036
When the latter URI comes in, I use Apache mod_rewrite to decide where to direct the request. In the Apache configuration I provide a few rules, such as "if the file requested doesn't exist in the normal file system as either a file or a directory, it goes to index.php". With that rule, Apache translates all non-existing file paths to go to index.php (without using a custom 404 document) . In index.php I can analyze the file path, query the database, authenticate, output the binary file, web page, or whatever's being requested. For better or worse what I've done is create a file system of my own.
I think that's the best method to control file access, personally, because it allows for so many more possibilities.
Regards,
Rich
--
[
http://www.smilingsouls.net]
Mail_IMAP: A PHP/C-Client/PEAR solution for webmail
Author: Beginning CSS: Cascading Style Sheets For Web Design