Solved

Error while downloading pdf file

Posted on 2011-03-22
7
1,496 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
Space-Age Communications Transitions to DevOps

ViaSat, a global provider of satellite and wireless communications, securely connects businesses, governments, and organizations to the Internet. Learn how ViaSat’s Network Solutions Engineer, drove the transition from a traditional network support to a DevOps-centric model.

 
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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering 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

Suggested Solutions

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…
This article aims to explain the working of CircularLogArchiver. This tool was designed to solve the buildup of log file in cases where systems do not support circular logging or where circular logging is not enabled
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

840 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