PDF Handler : content-disposition filename

user2062308 picture user2062308 · Feb 11, 2013 · Viewed 51.4k times · Source

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?

Answer

Julian Reschke picture Julian Reschke · Feb 12, 2013

See test cases at http://greenbytes.de/tech/tc2231/#inlwithasciifilenamepdf - it seems that this is simply a missing feature in IE.