Use Asp.net to hide the actual download address (simple anti-leech protection can be implemented)

Source: Internet
Author: User

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

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.