asp.net 想downlaod file

2007-09-27 1:10 pm
如果要用asp.net 2.0 downlaod 回file, 但不想被其他人看到path,可以怎樣做?
有沒有example 可以參考?
更新1:

如果這樣做會不會client copy 條link開個新browse 就可以download 回一樣的東西, 好似secrity 唔係咁好,還有咩方法...?

回答 (1)

2007-09-28 11:10 am
✔ 最佳答案
You use pure html to download a file.
<a href="http://www.abcdefg.com/download.zip">Download File</a>

With asp.net hyperlink control
asp_hyperlink_control.NavigateUrl = "http://www.abcdefg.com/download.zip"
asp_hyperlink_control.Text = Download File

You cannot hide the path. Wthout the path, how does the browser know where to send the request to?

The best you can do is to put the download code in an external javascript file. The script tag points the src to the javascript file.

<a href="#" onclick="downloadFile()">Download File</a>

In external javascript file:
function downloadFile()
{
document.location.href = 'http://www.abcdefg.com/download.zip';
}



2007-10-01 12:29:05 補充:
The best way is to require the user to supply a password before he can go to the download page.
參考: Will you cancel me?


收錄日期: 2021-04-25 20:34:11
原文連結 [永久失效]:
https://hk.answers.yahoo.com/question/index?qid=20070927000051KK00486

檢視 Wayback Machine 備份