I’m looking to implement a way to keep files private so they cant be publicly re-downloaded and only allow the server side code (like a button) to pull them from a private directory for the client on a one time basis.
Is that even possible?
Even if the folder is publicly available, What is a good way of firing an event that makes how many times the file has been downloaded so i can track that and make a service that deletes them after they’ve reached a download limit? I suppose i could just do a Response.redirect to the file and then the logic to track how many times its been downloaded. But is that the way you would do it?
EDIT: After some digging i’ve found a solution. I know many of you have downvoted this for not including sample code but I would appreciate if you can upvote it back for sharing the code I ended up using for it, since it works quite well.
String FileName = "File.zip";
String FilePath = "C:/Test/" + FileName; //Replace this
System.Web.HttpResponse response = System.Web.HttpContext.Current.Response;
response.ClearContent();
response.Clear();
response.ContentType = "text/plain";
response.AddHeader("Content-Disposition", "attachment; filename=" + FileName + ";");
response.TransmitFile(FilePath);
response.Flush();
response.End();
After some digging i’ve found a solution. I know many of you have downvoted this for not including sample code but I would appreciate if you can upvote it back for sharing the code I ended up using for it, since it works quite well.