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.
Online Training Solution

Drastically shorten your training time with WalkMe's advanced online training solution that Guides your trainees to action. Forget about retraining and skyrocket knowledge retention rates.

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

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Introduction In the following article I’ll be discussing and demonstrating several different ways of how images can be put on a report. I’m using SQL Server Reporting Services 2008 R2 CTP, more precisely version 10.50.1352.12, but the methods ex…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

705 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