Issues sending output of Crystal Reports to a browser

Posted on 2007-08-11
Last Modified: 2010-04-15
I have written an application (C#) which uses crystal reports to generate reports in excel, pdf, or rtf format.  It then sends these files to the browser for display.  This works perfectly on most machines, but every now and then the machines won't display the file.  Sometimes the browser beeps and closes the window AFTER opening a new window and downloading the file (even if all popup blockers are off)  My question is why, and how do I fix this?

Some other details... Solutions that have worked so far but are either not good enough or are unexplainable...

1) On most machines with this problem... unibstalling adobe and reinstalling fixes the problem for all 3 file types.  I understand why it fixes pdf, but....

2) If I set "always prompt for file download" under internet settings, the user gets a download dialog and can save it or even (sometimes) open it straight in this browser.  This works, but it makes the app inelegant.

Is there a better way?

PS.  Here is the C# code for display (which is basically a copy of suggested code from Business Object support)

private void ShowMyReport()
     string extension="";
     //Clear the response, so we can just send the file
    //Set up the format of the export
    switch (Session["ReportFormat"].ToString().Trim().ToUpper())
          case "PDF":
                 Response.ContentType = "application/pdf";
                  Response.AppendHeader ("Content-Disposition", "Filename=Report.pdf");
                 extension = ".pdf";
          case "XLS":
      Response.ContentType = "application/xls";
      Response.AppendHeader ("Content-Disposition", "Filename=Report.xls");
      extension = ".xls";
          case "RTF":
      Response.ContentType = "text/rtf";
      Response.AppendHeader ("Content-Disposition", "Filename=Report.rtf");
      extension = ".rtf";
//Now set up where to get the file from.
string exportFileName = Session["ExportFileName"].ToString();
//Dump the file to the web browser

//Now get rid of the pesky file off the server.
   //Let the page display.
Question by:Miriam0000
    LVL 9

    Expert Comment

    You might want to try getting rid of the Response.Close statement.  In my experience I've never used that statement and perhaps that is causing some issues.  For instance, it may be closing the response before some other code gets a chance to interact with it.

    Otherwise your code looks right to me.
    LVL 2

    Author Comment

    That didn't do it.  I think it has t do with IE settings n the client but I can't figure out how to change them
    LVL 9

    Accepted Solution

    Your description of the 'beep' and window closing really does sound like a pop-up blocker.  Are you sure one isn't secretly running on some of these machines?  I've seen that happen with developers who forgot about the Google or Yahoo toolbar's popup blocker.

    You could try running the page on a different browser to see if it really is IE related.  Load up Firefox on those machines that are having issues.

    You may want to check Adobe's knowledgebase for help on why uninstalling and reinstalling makes a difference.  If it works, go with it.

    In summary, I don't see anything wrong with your ASP.NET code.  And since this works on most machines, logically the issue is with the machine.  

    You may have some luck posting this issue in the IE forum since it sounds like more of a browser configuration issue.  Sorry I can't help more than that.
    LVL 9

    Expert Comment

    One last thing, since you mentioned "you can't figure out how to change [the IE settings]", are you in a position to use Group Policies to manage IE settings?  If it turns out a certain setting is causing an issue you can use GP or look into the IEAK7.0 to manage IE settings centrally.
    LVL 2

    Author Comment

    Thank you for your time and help.  I will try the IE forum and see where I get.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Why You Should Analyze Threat Actor TTPs

    After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

    Hello everyone, Hope you find this as helpful as we did. We have on the company I work for an application built in Delphi V with Crystal Reports 8. We all know that Crystal & Delphi can be temperamental sometimes and the worst thing is, nearly…
    Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
    It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
    In this sixth video of the Xpdf series, we discuss and demonstrate the PDFtoPNG utility, which converts a multi-page PDF file to separate color, grayscale, or monochrome PNG files, creating one PNG file for each page in the PDF. It does this via a c…

    779 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

    13 Experts available now in Live!

    Get 1:1 Help Now