PDF处理程序:内容处置文件名 [英] PDF Handler : content-disposition filename
问题描述
我正在Web浏览器(IE8)HttpContext.Response.writefile(fileName)
中输出PDF文件,并且效果很好.当我尝试保存文件时,它将为我提供ashx处理程序的名称作为默认名称.我实际上想传递真实姓名.
我尝试添加标题信息,如下所示:
context.Response.AddHeader("content-disposition", "attachment; filename=" + fileInfo.Name);
它可以工作,但我不希望用户在打开和保存之间进行选择,我希望文件正常打开,如果用户选择保存,则对话框将为他/她提供默认文件名./p>
我也尝试过:
context.Response.AddHeader("content-disposition", "inline; filename=" + fileInfo.Name);
或者,就像 Scott Hanselman在他的博客中建议的.
context.Response.AddHeader("content-disposition", "filename=" + fileInfo.Name);
这些都不适合我.有人有什么主意吗?
请参见 http:/上的测试用例./greenbytes.de/tech/tc2231/#inlwithasciifilenamepdf -似乎这只是IE中缺少的功能.
I am outputting a PDF file in a Web browser (IE8) HttpContext.Response.writefile(fileName)
and it works great. When I try to save the file, it will give me the name of the ashx handler as a default. I would like to actually pass the real name.
I tried to add header information as follow:
context.Response.AddHeader("content-disposition", "attachment; filename=" + fileInfo.Name);
And it works but I do not want the user to have to choose between open and save, i want the file to open normally and if the user chooses to save it then the dialog would give him/her the default filename.
I tried also:
context.Response.AddHeader("content-disposition", "inline; filename=" + fileInfo.Name);
Or just, like Scott Hanselman suggested in his blog.
context.Response.AddHeader("content-disposition", "filename=" + fileInfo.Name);
None of those work for me. Does anybody have any ideas?
See test cases at http://greenbytes.de/tech/tc2231/#inlwithasciifilenamepdf - it seems that this is simply a missing feature in IE.
这篇关于PDF处理程序:内容处置文件名的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!