Solved

Error while downloading pdf file

Posted on 2011-03-22
7
1,445 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
Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

A recent question popped up and the discussion heated up regarding updating a COMMENTS (TXT) field in a table using SSRS. http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/MS-SQL_Reporting/Q_27475269.html?cid=1572#a37227028 (htt…
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…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.

747 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

13 Experts available now in Live!

Get 1:1 Help Now