Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2010-09-03
3
Medium Priority
?
1,967 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

Ask an Anonymous Question!

Don't feel intimidated by what you don't know. Ask your question anonymously. It's easy! Learn more and upgrade.

Question has a verified solution.

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

One of the pain points with developing AJAX, JavaScript, JQuery, and other client-side behaviors is that JavaScript doesn’t allow for cross domain request for pulling content. For example, JavaScript code on www.johnchapman.name could not pull conte…
Sometimes in DotNetNuke module development you want to swap controls within the same module definition.  In doing this DNN (somewhat annoyingly) swaps the Skin and Container definitions to the default admin selections.  To get around this you need t…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

636 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