ASP.NET 4: HttpResponse open in NEW Browser?

六月ゝ 毕业季﹏ 提交于 2019-12-02 12:59:45

You cannot do that on server side if you have not generated the link yourself. But if you have, then as Robert said, provide a target with the <a> link.

There is a server-side alternative and that is to set the content type to application/octect-stream so that the file is download and user will be able to open it with the application of choice outside browser. See here for more.

You also need to use content disposition header to provide the file name so that client can know what file type is it after it has been downloaded as binary.

Content-Disposition: attachment; filename=my.pdf;

You presumably have a link on your site that directs the user to the URL where this PDF generation is done. In that link, add target="_blank" to the <a> tag.

If what you're really asking is how to make the save dialog to show instead of having the PDF loaded into your browser, then you need to modify your header. You are setting Content-Disposition to 'inline', change that to 'attachment'

http://support.microsoft.com/kb/260519

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!