Share via


Crystal Report not showing in browser

Question

Tuesday, October 6, 2015 12:16 AM

Hi, Iam using CrystalReport in my application.iam using VS2010. connections are working fine and . my problem is after adding crystal report and set connection, add a webpage and drag a CrystalReportViewer from tool box and wrote following code in load event

ReportDocument reportdocument = new ReportDocument();

reportdocument.Load(Server.MapPath("~/CrystalReport.rpt"));

CrystalReportViewer1.ReportSource = reportdocument;

it is not showing crystalreport in browser. and not showing any error.

How to solve this

Regards

Baiju

All replies (2)

Wednesday, October 14, 2015 3:26 AM

i never used crystalreportviewer but it's possible to convert export your report to a stream as pdf or word then add it to the context response and your file will be shown in browser or be downloaded depending on browser settings and plugins

var stream = currentReport.ExportToStream(CrystalDecisions.[Shared].ExportFormatType.PortableDocFormat);
var pdfbyteArray = new byte[stream.length -1];

stream.Position = 0;
stream.read(pdfbyteArray, 0, Convert.ToInt32(stream.length))
Context.Response.ClearContent();
Context.Response.ClearHeaders();
Context.Response.AddHeader("content-disposition", "filename=Report.pdf");
Context.Response.ContentType = "application/pdf";
Context.Response.AddHeader("content-length", pdfbyteArray.Length.ToString());
Context.Response.BinaryWrite(pdfbyteArray);

code has been written here in the forum so not all caps might be right but i think you get the idea. :) might also use "using" with the stream 


Thursday, October 15, 2015 4:24 AM

Hi klbaiju,

Crystal Report not showing in browser

The following are some common cause of this error in VS 2010.

  • The Crystal Reports viewer folder is not configured correctly
  • The default CR runtime install (MSM or MSI) will only configure the viewer for a default application pool
  • When using a custom application pool, the viewer must be configured manually

You could try to use the following solution:

  • Copy the folders under "\inetpub\wwwroot\aspnet_client\ and paste them under the  root of the custom web site
  •  Add the following to the application web.config file:
<configSections>
    <sectionGroup name="businessObjects">     
      <sectionGroup name="crystalReports">       
        <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler"/>     
 </sectionGroup>    
</sectionGroup>  
</configSections>   
<businessObjects>   
  <crystalReports>    
    <crystalReportViewer>        
      <add key="UseBrowserLocale" value="true"/>        
<add key="resourceURI" value="~/aspnet_client/system_web/4_0_30319/crystalreportviewers13" />      
</crystalReportViewer>    
</crystalReports>  
</businessObjects>

For more details, please refer to the following articles:

http://search.sap.com/ui/notes?id=0001720670&boj=/sap/bc/bsp/spn/scn_bosap/notes.do?access=69765F6D6F64653D3939382669765F7361706E6F7465735F6E756D6265723D30303031373230363730&ssocompatible

http://forums.asp.net/t/1673216.aspx?Crystal+Report+not+showing+in+Crystal+Reports+Viewer

http://scn.sap.com/thread/3387194

Best regards,
Dillion