Solved

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

Posted on 2010-09-03
3
1,860 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
  • 2
3 Comments
 
LVL 5

Accepted Solution

by:
JayFromPep earned 250 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Idea or tool for building a form application using ASP.net MVC 2 38
Hovering effect 9 46
Adjust the position 3 48
Asp.net mvc foreach 3 34
Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …

911 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

17 Experts available now in Live!

Get 1:1 Help Now