Error while downloading pdf file

Posted on 2011-03-22
Last Modified: 2012-05-11
Error Message
Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), response filters, HttpModules, or server trace is enabled.
Details: Error parsing near '%PDF-1.3%1  0 obj

code used

 private void downloadSubmittalReport(byte[] byteSubmittalReport, string filename)
            Response.ContentType = "application/ms-excel";
            Response.AddHeader("content-disposition", "attachment;filename=" + filename.Trim() + ".pdf");
            Response.OutputStream.Write(byteSubmittalReport, 0, byteSubmittalReport.Length);

Open in new window

iam passing the byte from Rdl which are available in Reporting server  .

can you please help us ASAP
Question by:Rajkumar Gs
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2

Accepted Solution

nbove earned 425 total points
ID: 35191923
Try changing your code to the following:
Response.ContentType = System.Net.Mime.MediaTypeNames.Application.Pdf;
Response.AddHeader("content-disposition", "attachment; filename=form.pdf");
Response.OutputStream.Write(byteSubmittalReport, 0, byteSubmittalReport.Length);
LVL 23

Author Comment

by:Rajkumar Gs
ID: 35196183
Thanks nbove,
I will try this and will be back soon
LVL 12

Assisted Solution

Hairbrush earned 75 total points
ID: 35198716

I agree with nbove.  In explanation, you are telling the user agent on the client to expect a stream of Excel data but with a PDF file extension.  The data really is a PDF, but when the client tries to open it with Excel, it won't know how to read the PDF data.

When you change the ContentType to PDF then the correct application on your client will open - for example your browser will load the Acrobat plug-in.
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 23

Author Comment

by:Rajkumar Gs
ID: 35280656
This is issue was solved in a different way. I will explain how it was done.

Sorry for the delay to post back. I was so busy with production release.


Expert Comment

ID: 35287242
If this issue has been resolved, please mark the question as resolved.
LVL 23

Assisted Solution

by:Rajkumar Gs
Rajkumar Gs earned 0 total points
ID: 35426966
When we tried the first suggestion using iframe alone, it was working.

But when we tried iframe with infopath form from Sharepoint, it was not working.

So we moved the download linkbutton to new page, and used the first suggestion - it is working now.
LVL 23

Author Closing Comment

by:Rajkumar Gs
ID: 35455576
Thanks you both.
I know this solution. But our initial requirement was with infopath / Sharepoint, in which we couldn't get this work


Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

733 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