ASP.NET直接打开文档,而不出现下载的提示,求教 <a target="_blank" href="http://ss/xx.doc">X</a> 这是直接弹出对话框询问打开还是下载,能不是直接打开,而不是弹出对话框再选择 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 doc,pdf什么的支持IE打开的.可以做一个下载页面啊 to jadezhou83呵呵,我的意思就是你的a标签的链接url就不要指向具体的下载文件,而是统一的一个下载页面(那个页面上可以构造标签<a target="_blank" href="http://ss/xx.doc">X</a> )比如原来你的a 标签所在页面可以<a target="_blank" href="http://ss/xx.aspx?fileid="+param>X</a> //param是下载文件的唯一标识然后统一下载页面(xx.aspx)就可以通过fileid来构造出以下标签,用户点击就可以实现你的要求了<a target="_blank" href="http://ss/xx.doc">X</a> 如果是文本的话,用连接只能打开,不能出现下载对话框的你用下面的试试我在做上传下载的时候用的: System.IO.FileInfo objFileInfo; if (System.IO.File.Exists(PhysicalPath)) { objFileInfo = new System.IO.FileInfo(PhysicalPath); System.Web.HttpContext.Current.Response.Clear(); System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + objFileInfo.Name); System.Web.HttpContext.Current.Response.AddHeader("Content-Length", objFileInfo.Length.ToString()); System.Web.HttpContext.Current.Response.ContentType = FileType; System.Web.HttpContext.Current.Response.WriteFile(objFileInfo.FullName); System.Web.HttpContext.Current.Response.End(); } else { Page.ClientScript.RegisterStartupScript(this.GetType(), "a", "<Script>alert('文件不存在!');</Script>"); }PhysicalPath 下载文件的路径FileType 下载文件的类型 用Response输出来注意文件类型 vs05里CSS效果出不来 ASP.NET网站的详细设计说明书怎么写 关于跨网页加载数据 点击button后如何弹出确认框? 在线急等action提交的问题 ASP.NET1.1 升级到2.0 要重新安装吗? 重大决定 请各位提点意见! 奇怪的问题 如何在类文件中访问page对象? 招聘asp.net工程師兩名(深圳) 一个关于记数的问题~~在线等 找GridView数据绑定列(BoundField)里的控件,并取出控件中的值
呵呵,我的意思就是你的a标签的链接url就不要指向具体的下载文件,而是统一的一个下载页面(那个页面上可以构造标签<a target="_blank" href="http://ss/xx.doc">X</a> )
比如原来你的a 标签所在页面可以
<a target="_blank" href="http://ss/xx.aspx?fileid="+param>X</a>
//param是下载文件的唯一标识
然后统一下载页面(xx.aspx)就可以通过fileid来构造出以下标签,用户点击就可以实现你的要求了
<a target="_blank" href="http://ss/xx.doc">X</a>
你用下面的试试
我在做上传下载的时候用的:
System.IO.FileInfo objFileInfo;
if (System.IO.File.Exists(PhysicalPath))
{
objFileInfo = new System.IO.FileInfo(PhysicalPath);
System.Web.HttpContext.Current.Response.Clear();
System.Web.HttpContext.Current.Response.AddHeader("Content-Disposition", "attachment;filename=" + objFileInfo.Name);
System.Web.HttpContext.Current.Response.AddHeader("Content-Length", objFileInfo.Length.ToString());
System.Web.HttpContext.Current.Response.ContentType = FileType;
System.Web.HttpContext.Current.Response.WriteFile(objFileInfo.FullName);
System.Web.HttpContext.Current.Response.End();
}
else
{
Page.ClientScript.RegisterStartupScript(this.GetType(), "a", "<Script>alert('文件不存在!');</Script>");
}PhysicalPath 下载文件的路径
FileType 下载文件的类型
注意文件类型