Solved

ASP.Net write PDF to browser shows garbage in IE

Posted on 2014-01-31
1
378 Views
Last Modified: 2014-02-05
Hi.. I have the following code that writes and shows a PDF file in a brower.
Works great in Chrome.. In IE I get a bunch of garbage characters.

Like this

%PDF-1.6 %ÓôÌá 1 0 obj..........

Any ideas
thx


                Response.Clear();
                Response.ContentType = res.MimeType;

                Response.Cache.SetCacheability(HttpCacheability.Private);
                Response.Expires = -1;
                Response.Buffer = false;

                this.Response.BinaryWrite(res.DocumentBytes);
                this.Response.End();
0
Comment
Question by:JElster
1 Comment
 
LVL 7

Accepted Solution

by:
XGIS earned 500 total points
ID: 39824639
Hello Jelster..
maybe it is due to the bug related to nocache headers.  this code may help
Response.Expires = -1
    Response.Cache.SetNoStore()
    Response.AppendHeader("Pragma", "no-cache")
    Response.ContentType = "application/pdf"
    Response.BinaryWrite(myByteBuffer)
    Response.Flush()
    Response.Close()

Open in new window

0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

911 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

24 Experts available now in Live!

Get 1:1 Help Now