PDF处理程序问题与Chrome&火狐 [英] PDF Handler Problem with Chrome & Firefox
问题描述
好了,我解决了访问PDF文件时内存不足的问题,但现在看起来,当我尝试通过Chrome或Firefox访问大文件时,我收到了乱码。它不打开Adobe,只是将它显示为包含数百万个字符的页面。我使用下面的代码来获得它给用户,为什么会这样做的任何想法?
Well I solved the problem of running out of memory when accessing the PDF files, but now it seems that when I try to access big files via Chrome or Firefox I get gibberish. It doesn't open Adobe, it just display it as a page with millions of characters. Im using the code below to get it to the user, any ideas on why it would be doing this?
case "PDF":
context.Response.ContentType = "application/pdf";
context.Response.AddHeader("content-disposition", "inline; filename=" + asset.A_Name);
}
context.Response.BinaryWrite(content);
推荐答案
您必须将内容长度标题添加到响应。它是IIS分块编码的一个问题。查看此处。
You have to add a content length header to the response. Its a problem with IIS chunked encoding. Look here.
context.Response.AddHeader(Content-Length,fileInfo.Length.ToString())
;
这篇关于PDF处理程序问题与Chrome&火狐的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!