2009-11-28 28 views
0

我已经从数据库中检索到pdf文件并将其链接到“a href”标签以使用链接打开pdf文件。现在我想在打开pdf文件之前给出打开/保存对话框。 - 在JavaScript(通过使用的onclick事件中的“一”的标签,以调用JavaScript)在asp.net中从DB-检索pdf文件的链接

回答

2

你必须设置使用C#来获得在浏览器这种行为内容处置头。

阅读更多信息

How do I prompt a "Save As" dialog for an accepted mime type?

Downloading a File with a Save As Dialog in ASP.NET

Response.Clear(); 
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); 
Response.AddHeader("Content-Length", targetFile.Length.ToString); 
Response.ContentType = "application/pdf"; 
Response.WriteFile(targetFile.FullName); 
+0

+1,这里的另一个相关的SO职位:http://stackoverflow.com /问题/ 1024910 /允许用户对下载从-M Y形通响应,WriteFile的 – 2009-11-28 05:44:30