Solved

Error while downloading pdf file

Posted on 2011-03-22
7
1,475 Views
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.Clear();
            Response.ContentType = "application/ms-excel";
            Response.AddHeader("content-disposition", "attachment;filename=" + filename.Trim() + ".pdf");
            Response.OutputStream.Write(byteSubmittalReport, 0, byteSubmittalReport.Length);
            Response.OutputStream.Flush();
            Response.OutputStream.Close();
            Response.Flush();
            Response.Close();
}

Open in new window


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

can you please help us ASAP
0
Comment
Question by:Rajkumar Gs
  • 4
  • 2
7 Comments
 
LVL 7

Accepted Solution

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

Author Comment

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

Assisted Solution

by:Hairbrush
Hairbrush earned 75 total points
ID: 35198716
Raj

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.
0
3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

 
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.

Raj
0
 
LVL 7

Expert Comment

by:nbove
ID: 35287242
If this issue has been resolved, please mark the question as resolved.
0
 
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.
0
 
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

Raj
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only see…
Occasionally there is a need to clean table columns, especially if you have inherited legacy data. There are obviously many ways to accomplish that, including elaborate UPDATE queries with anywhere from one to numerous REPLACE functions (even within…
This tutorial gives a high-level tour of the interface of Marketo (a marketing automation tool to help businesses track and engage prospective customers and drive them to purchase). You will see the main areas including Marketing Activities, Design …
This video shows how to quickly and easily add an email signature for all users on Exchange 2016. The resulting signature is applied on a server level by Exchange Online. The email signature template has been downloaded from: www.mail-signatures…

816 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

6 Experts available now in Live!

Get 1:1 Help Now