?
Solved

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

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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

In .NET 2.0, Microsoft introduced the Web Site.  This was the default way to create a web Project in Visual Studio 2005.  In Visual Studio 2008, the Web Application has been restored as the default web Project in Visual Studio/.NET 3.x The Web Si…
A quick way to get a menu to work on our website, is using the Menu control and assign it to a web.sitemap using SiteMapDataSource. Example of web.sitemap file: (CODE) Sample code to add to the page menu: (CODE) Running the application, we wi…
Is your OST file inaccessible, Need to transfer OST file from one computer to another? Want to convert OST file to PST? If the answer to any of the above question is yes, then look no further. With the help of Stellar OST to PST Converter, you can e…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month14 days, 14 hours left to enroll

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