How does Asp.net implement the thunder download function?

Source: Internet
Author: User

Http://hi.baidu.com/xiaohuizuan/blog/item/95355933bc3ab7fe14cecb3f.html

 

I made a website a few days ago. I used the thunder download function and found it online.CodeI sorted it out. Now I have shared it with you.

First, configure the information on the. ASPX page.

<SCRIPT runat = Server> Public String thunderencode (string code) {code = "AA" + code + "ZZ"; string encode = ""; byte [] bytes = encoding. getencoding (1, 54936 ). getbytes (CODE); try {encode = convert. tobase64string (bytes);} catch {encode = Code;} return "Thunder: //" + encode;} </SCRIPT>

<SCRIPT src = "http://pstatic.xunlei.com/js/webThunderDetect.js"> </SCRIPT> <a href = "#" thunderhref = "<% = thunderencode (" http: // change to your own link. rar ") %> "thunderpid =" 57029 "thundertype =" "thunderrestitle =" "onclick =" Return ondownloadclick_simple (this, 2, 4) "oncontextmenu =" thundernetwork_sethref (this) "> fast download for thunder </a> <br/> <asp: button id =" button1 "runat =" server "text =" button "onclick =" button#click1 "/>

 

Then fill in the. CS File

Protected void button1_click1 (Object sender, eventargs e) {response. contenttype = "application/X-zip-compressed"; response. addheader ("content-disposition", "attachment?filename=z.zip"); string filename = server. mappath ("download file path"); response. transmitfile (filename );

}

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.