用户使用链接下载文件时如何不弹出页面?

Syberlee 2006-08-09 11:12:00
发Email给用户,Email中包括文件的URL

比如:

Mail:
http://www.***.com/download.aspx?FileName=test.txt

用户点击Mail中的这个链接,直接弹出下载的对话框,不显示download.aspx页面。

另外,如果test.txt不存在的话,返回一个window.alert("File is not exist!");

应该怎么实现。。。。。。

求教中。。。。。。
...全文
331 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
icejd 2006-08-25
  • 打赏
  • 举报
回复
你不要让他在新窗口打弄这个链接页面就行了,在下载页面中直接作地址转向

<a href=xxx.aspx>dfsdfsdfds</a>
xxx.aspx的内容
Response.Redirect(url);
就会直接弹出下载框,而不是弹出一个页面,再弹出一个下载框了
losteveb 2006-08-10
  • 打赏
  • 举报
回复
可以用javascipt关闭页面,给用户看起来就没弹出新页面
amingo 2006-08-09
  • 打赏
  • 举报
回复
http://community.csdn.net/Expert/topic/4937/4937220.xml?temp=.9042627
foyuan 2006-08-09
  • 打赏
  • 举报
回复
你吧DownLoad写成这样 应该不会下载了吧
public void Page_Load()
{
if(文件不存在)
Response.End()
else
Downloadfile()
}
public static void DownLoadFile(string fileName)
{
System.IO.FileInfo DownloadFile = new System.IO.FileInfo(fileName);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.ClearHeaders();
System.Web.HttpContext.Current.Response.Buffer=false;
System.Web.HttpContext.Current.Response.ContentType="application/octet-stream";
System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition","attachment;filename=" +System.Web.HttpUtility.UrlEncode(DownloadFile.FullName,System.Text.Encoding.UTF8));
System.Web.HttpContext.Current.Response.AppendHeader("Content-Length",DownloadFile.Length.ToString());
System.Web.HttpContext.Current.Response.WriteFile(DownloadFile.FullName);
System.Web.HttpContext.Current.Response.Flush();
System.Web.HttpContext.Current.Response.End();
}
amingo 2006-08-09
  • 打赏
  • 举报
回复
请教
http://community.csdn.net/Expert/topic/4937/4937220.xml?temp=.5492823
leafsword_519 2006-08-09
  • 打赏
  • 举报
回复
不显示download.aspx页面??行么?
zlkingdom 2006-08-09
  • 打赏
  • 举报
回复
好象不能阻止打开这个页面,但是可以用javascript将页面打开后马上再关掉,下载还是可以继续的
flyzq 2006-08-09
  • 打赏
  • 举报
回复
把下在的fuction放在download.aspx的page_load里面
if(test.txt不存在)
{
window.alert("File is not exist!");
}
else
{
download function();
]

62,074

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术交流专区
javascript云原生 企业社区
社区管理员
  • ASP.NET
  • .Net开发者社区
  • R小R
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

.NET 社区是一个围绕开源 .NET 的开放、热情、创新、包容的技术社区。社区致力于为广大 .NET 爱好者提供一个良好的知识共享、协同互助的 .NET 技术交流环境。我们尊重不同意见,支持健康理性的辩论和互动,反对歧视和攻击。

希望和大家一起共同营造一个活跃、友好的社区氛围。

试试用AI创作助手写篇文章吧