禁用文件下载提示“是否要打开或保存此文件?” [英] Disable File Download prompt "Do you want to open or save this file?"

查看:655
本文介绍了禁用文件下载提示“是否要打开或保存此文件?”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用asp.net,每次尝试打开pdf或.fdf文件时,都会出现一个Windows提示符,询问"是否要打开或保存此文件?"相反,如果它只是在浏览器窗口中打开。

I'm using asp.net and everytime I try to open a pdf or a .fdf file I get a windows prompt asking "Do you want to open or save this file?" instead if it just opening in the browser window.

有关如何关闭它的任何帮助表示赞赏。

Any help on how to turn this off is appreciated.

谢谢

推荐答案

//在wirte响应pdf文件之前添加标题:
Response.Response.ContentType ="application / pdf";
//当然客户端至少需要安装Adobe Reader。

//before wirte to response the pdf file add header:
Response.Response.ContentType = "application/pdf";
//of course the client need at least Adobe Reader installed.

//如果你确实需要强制下载对话框,那么添加另一个标题:
Response.AddHeader("content-disposition", "attachment; filename = filename.pdf");

//and if you do need to force a download dialog then add another header:
Response.AddHeader("content-disposition", "attachment; filename=filename.pdf");


这篇关于禁用文件下载提示“是否要打开或保存此文件?”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆