简体   繁体   中英

Save As Dialog box in asp.net

我有Web应用程序(asp.net)。当用户单击下载按钮时,有没有办法显示``另存为对话框''(在浏览器中)。我尝试了几种代码,但未得到预期的结果。所有通常可以下载文件进行下载(浏览器的默认下载路径)。是否可以在Web浏览器中打开另存为对话框

Probably you're looking for download a file in asp.net? Please see sample below.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM