开发者

PDF Handler Problem with Chrome & Firefox

开发者 https://www.devze.com 2023-03-22 12:32 出处:网络
Well I solved the problem of running out of memory when accessing the PDF files, but now it seems that when I try to acc开发者_如何学Cess big files via Chrome or Firefox I get gibberish. It doesn\'t o

Well I solved the problem of running out of memory when accessing the PDF files, but now it seems that when I try to acc开发者_如何学Cess 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);


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


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

0

精彩评论

暂无评论...
验证码 换一张
取 消