PDF Handler Problem with Chrome & Firefox

拥有回忆 提交于 2019-12-24 21:22:43

问题


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);

回答1:


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());




回答2:


Has anything already been written to the Response stream? Make sure to call Response.Clear() first.



来源:https://stackoverflow.com/questions/6793264/pdf-handler-problem-with-chrome-firefox

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