Recently I have been trying to figure out a simple (?) way to protect files or content. I do not want to hassle with adjusting file permissions programmatically. I was trying to selectively allow users to download MS Word Docs and here is what I have come up with so far.
string sPath = Server.MapPath("file.doc");
Response.ContentType = "application/msword";
Response.WriteFile(sPath);Response.ContentType = "application/msword";
Response.WriteFile(sPath);
This seems to work okay, but I am not aware of all the security applications or concerns. Also, how to programmatically change the file download name... Of course you have to deny permission of the IUSR to the protected file.