Use Asp.net to hide real download addresses (simple anti-leech protection can be implemented)

Source: Internet
Author: User
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 addresses for 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 can discuss it as follows: String Filename =   " 51aspx_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. Please contact the 51aspx administrator!");
}
}

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 ~~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.