动态读取文件,页面如何下载
譬如我的一个地址test.aspx?id=12345是指向一个文件的,当打开这个地址时,我后台读取数据库,把文件输出来;现在,如果我直接<a href='test.aspx?id=12345'>下载</a>,那么它会直接在页面上打开文件,并且页面显示乱码,
我应该在页面上怎么做,才能当点击'test.aspx?id=12345'时,可以弹出一个现实框,有“保存”,“下载”,“取消”按钮 --------------------编程问答--------------------
--------------------编程问答-------------------- 顶 --------------------编程问答--------------------
private void DoDownload()
{
Uri fileUrl = new Uri("http://www.codeproject.com" +
"/info/stuff/cp_bg_black1024.gif");
string tempPath = Path.GetTempPath();
string fileName = Path.GetFileName(fileUrl.AbsoluteUri);
string downloadPath = Path.Combine(tempPath, fileName);
FileDownloader downloader = new FileDownloader();
downloader.Proxy = WebRequest.DefaultWebProxy;
downloader.Credentials = CredentialCache.DefaultCredentials;
downloader.DownloadCompleted += new
EventHandler(OnDownloadCompleted);
downloader.DownloadProgressChanged += new
EventHandler(
OnDownloadProgressChanged);
downloader.DownloadStatusChanged += new
EventHandler(
OnDownloadStatusChanged);
// Download the requested file to the specified folder
downloader.Download(fileUrl, tempPath);
}
楼上的这种指向文件cp_bg_black1024.gif的情况不适用 --------------------编程问答-------------------- 与客户端的浏览器设置有关 --------------------编程问答--------------------
如何设置
补充:.NET技术 , ASP.NET