关于页面上的文件超链接 页面上的文件超链接,就是一些附件下载。直接点击后。如果是DOC文件,那么会提示下载还是打开,如果是打开,那么就会直接在本页面打开。如果是TXT文件,那么不会询问用户,会直接在本页面打开。我想让所有类型文件的超链接在点击后都是询问 下载还是打开。并且打开的话,不在本页面打开,而是运行关联程序打开。请问该怎么弄。。先谢了 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <a href="download.aspx?id="/>download.aspx页面查询IDstring fileName = "";//客户端保存的文件名 string filePath = Server.MapPath("");//路径 FileInfo fileInfo = new FileInfo(filePath); Response.Clear(); Response.ClearContent(); Response.ClearHeaders(); Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName); Response.AddHeader("Content-Length", fileInfo.Length.ToString()); Response.AddHeader("Content-Transfer-Encoding", "binary"); Response.ContentType = "application/octet-stream"; Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312"); Response.WriteFile(fileInfo.FullName); Response.Flush(); Response.End(); 我想写一个ASP.net 的网站,我想实现下棋的功能。不想用flash 关于实现支付宝接口问题(就39分了,别闲少) 面试的一道菜鸟题 dropdownlist回发到服务器后为什么取不到值??? 求ASP.net上传文件代码 如何用dataset中表的一个字段 动态添加treeview得节点?? 货币类型的字段怎么写insert语句?急~~ 如何返回前一个提交页面?急急急! asp.net mvc3 查询分页出现问题 求asp.net在线视频播放的一个实例 javascrpt如果获取当前文件的绝对路径?? 请教:ASP.NET连接SYBASE乱码的解决方法?
download.aspx页面
查询ID
string fileName = "";//客户端保存的文件名
string filePath = Server.MapPath("");//路径 FileInfo fileInfo = new FileInfo(filePath);
Response.Clear();
Response.ClearContent();
Response.ClearHeaders();
Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
Response.AddHeader("Content-Length", fileInfo.Length.ToString());
Response.AddHeader("Content-Transfer-Encoding", "binary");
Response.ContentType = "application/octet-stream";
Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
Response.WriteFile(fileInfo.FullName);
Response.Flush();
Response.End();