?
Solved

writing crystal report to reponse using ExportToHttpResponse only works with server.transfer

Posted on 2010-09-03
3
Medium Priority
?
1,948 Views
Last Modified: 2012-08-14
Hi all,
Im trying to show a crystal report in pdf format in the browser but something very odd is going on and i cant work out why.

I have a page which lists reports (Reports.aspx)
I found the code below to generate a report in PDF format.
This code works fine when i have the code in a button click event in Reports.aspx.

People want the report in a different page so they can view a report,go back,choose another, go back etc..
So I created a new page (GenerateReport.aspx) put the code in page_load and did a reponse.redirect to GenerateReport.aspx in the button click event instead.
For some reason this doesnt work anymore! It just shows a blank screen.

I tried the code in page_load of the Reports.aspx page and it wont work either.
Even odder, if i change the Response.Redirect to Server.Transfer() it works!

I thought I could get away with Server.Transfer but users are closing the report window or clicking back and getting taken to the wrong page because Server.Transfer doesnt do a new request. Ive no idea why it works one way and not the other!
Has any one any ideas at all?
Thanks!!

IList<ReportData> myData = GetReportData();
CrystalReport1 myCrystalReport = new CrystalReport1();
myCrystalReport.SetDataSource(myData);

Response.Buffer = false;
Response.ClearContent();
Response.ClearHeaders();
myCrystalReport.ExportToHttpResponse(ExportFormatType.PortableDocFormat, Response, false, "ExportedReport");

Open in new window

0
Comment
Question by:enterpriseireland
[X]
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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
JayFromPep earned 750 total points
ID: 33618293
Server.Transfer works because it is passing the entire object, whereas Response.Redirect, redirects the user, leaving behind all of the stuff on the page you are leaving, unless you explicitly pass stuff forward.

so the myCrystalReport is killed on response.redirect, but lives on in Server.Transfer

Try passing the myCrystalReport into the Response.Redirect as a parameter and see if you can work with it that way.
0
 

Author Comment

by:enterpriseireland
ID: 33858290
I gave up on this.  I just had to do a fudge in the end. thanks for the help.
0
 

Author Closing Comment

by:enterpriseireland
ID: 33858296
wasnt full answer but was a good try :)
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

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

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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.…
Add bar graphs to Access queries using Unicode block characters. Graphs appear on every record in the color you want. Give life to numbers. Hopes this gives you ideas on visualizing your data in new ways ~ Create a calculated field in a query: …

764 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