在asp.net下载pdf,word,text文件 [英] Download pdf,word,text file in asp.net

查看:109
本文介绍了在asp.net下载pdf,word,text文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当点击pdf文件的下载按钮的链接时,它将在浏览器上打开,但我想在浏览器上打开时不打开它,我不想在浏览器上打开它....



所以plz在asp.net给出解决方案





提前谢谢





Mohit Agarwal

when click on link of download button for pdf file it will open on browser but i want to download it not on open on browser , i can not want open it on browser....

so plz give solution of this in asp.net


thank you in advance


Mohit Agarwal

推荐答案

string filename = "filename from Database";
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + filename);
string aaa = Server.MapPath("~/SavedFolder/" + filename);
Response.TransmitFile(Server.MapPath("~/SavedFolder/" + filename));
Response.End();







查看此链接, -

在ASP.NET中文件上载和下载 [ ^ ]


在这里你去



下载文件 - 强制文件下载对话框 [ ^ ]



在ASP.NET中使用另存为对话框下载文件 [ ^ ]
Here you go

Downloading Files - Forcing the File Download Dialog[^]

Downloading a File with a Save As Dialog in ASP.NET[^]


//download 
 Response.Redirect("~/UploadFolder/test.doc");
//upload
        string savePath= Server.MapPath("path");
        FileUpload1.SaveAs(savePath);


这篇关于在asp.net下载pdf,word,text文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆