在asp.net中另存为对话框

时间:2014-11-12 03:57:37

标签: c# asp.net browser savefiledialog

我有网络应用程序(asp.net)。当用户点击下载按钮时,有什么方法可以显示“在浏览器中保存”。我尝试了几个代码,但我没有& #39; t得到预期的结果。所有正常下载文件到下载(浏览器的默认下载路径)。是否可以在Web浏览器中打开另存为对话框

2 个答案:

答案 0 :(得分:1)

答案 1 :(得分:0)

您可能正在寻找在asp.net下载文件? 请参阅下面的示例。

Response.ContentType = "application/pdf";
Response.AppendHeader("Content-Disposition", "attachment; filename=MyFile.pdf");
Response.TransmitFile(Server.MapPath("~/Files/MyFile.pdf"));
Response.End();
.htm, .html     Response.ContentType = "text/HTML";
.txt    Response.ContentType = "text/plain";
.doc, .rtf, .docx    Response.ContentType = "Application/msword";
.xls, .xlsx    Response.ContentType = "Application/x-msexcel";
.jpg, .jpeg    Response.ContentType = "image/jpeg";
.gif    Response.ContentType =  "image/GIF";
.pdf    Response.ContentType = "application/pdf";

How to download a file in ASP.Net