asp.net如何?迅雷下載功能

來源:互聯網
上載者:User

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

 

前幾天做了一個網站,裡面用到了迅雷下載功能,在網上找了一下代碼整理了一下,現在拿出來了大家共用吧

首先在.aspx頁面配置資訊

<script runat=server> public string ThunderEncode(string code) { code="AA"+code+"ZZ"; string encode = ""; byte[] bytes = Encoding.GetEncoding(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://請改成你需要的連結.rar")%>" thunderPid="57029" thunderType="" thunderResTitle="" onClick="return OnDownloadClick_Simple(this,2,4)" oncontextmenu="ThunderNetwork_SetHref(this)" >迅雷專用高速下載</a> <br />         <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click1" />

 

然後再.cs檔案裡面填入

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("下載檔案路徑");         Response.TransmitFile(filename);

    }

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

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.