Reference
E-Channel win-win implementation in Asp.net (simple anti-leech protection can be implemented)
With the increasing popularity of download tools such as flashget and Xunlei, some download websites can be directly captured. However, in some cases, you do not want to expose the address to anti-leech protection or permission restrictions, there are many methods for anti-leech protection under Asp.net. I have written one here (the new version of 51aspx will be adopted). I hope you will discuss it: String filename = "test.rar ";
If (filename! = "")
{
String Path = server. mappath (filename );
System. Io. fileinfo file = new system. Io. fileinfo (PATH );
If (file. exists)
{
Response. Clear ();
Response. addheader ("content-disposition", "attachment; filename =" + file. Name );
Response. addheader ("Content-Length", file. length. tostring ());
Response. contenttype = "application/octet-stream ";
Response. writefile (file. fullname );
Response. End ();
}
Else
{
Response. Write ("this file does not exist! ");
}
}
Of course, this also has a drawback, that is, users can only download with a single ie thread. It doesn't matter if the size is small. If you have other better methods, please add them ~~ -----------------