链接从asp.net中的DB-检索pdf文件 [英] Link to retrieve pdf file from DB- in asp.net
本文介绍了链接从asp.net中的DB-检索pdf文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经从数据库中检索了pdf文件,并将其链接到"a href"标签以使用链接打开pdf文件.现在,我想在打开pdf文件之前给出打开/保存"对话框. -在javascript中(通过在"a"标签中使用 onclick 事件来调用javascript)
I have retrieved the pdf file from Database and linked it to a "a href" tag to open pdf file using link. Now I want to give the open/save dialog box before a pdf file opened . - in javascript(by using onclick event in "a" tag to call the javascript)
推荐答案
您必须使用C#设置 content-disposition 标头,才能在浏览器中获得此行为.
You have to set the content-disposition header using C# to get this behavior in a browser.
阅读以获取更多信息
示例
Example
Response.Clear();
Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName);
Response.AddHeader("Content-Length", targetFile.Length.ToString);
Response.ContentType = "application/pdf";
Response.WriteFile(targetFile.FullName);
这篇关于链接从asp.net中的DB-检索pdf文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文