Sometime back during a deployment some head banging occurred thanks to Crystal Reports hard-coding configuration in their application. The really irritating part is the configuration is configurable in the enterprise version. What configuration you ask? The location of the aspnet_client and CrystalReportsViewerX folders. By default Crystal Reports installs CrystalReportsViewerX folder to the default IIS web site,Default Web Site root, C:\inetpub\wwwroot\aspnet_client\system_web\2_0_50727 folder path. If you have a custom web site, for example, My Rocking Web Site, in most cases you can simply copy the aspnet_client/…/CrystalReportsViewerX folder to root of My Rocking Web Site physical path and all is good. What if you want to change the location of the aspnet_client folder? Please do not be mistaken by changing the shared location 12, the goal is to change the location of aspnet_client folder to say a virtual directory instead of the root.
You maybe asking yourself why do you want to change the location of aspnet_client folder?
Crystal Reports and BigIP
The reason is the web application in question leverages BigIP to transform the url from http to https. In a previous deployment our Silverlight configuration had to be altered to support BigIP too Hsoting Silverlight Over HTTP Under F5 Big IP.
By default Crystal Reports View folder, CrystalReportsViewer4, installs to C:\inetpub\wwwroot\aspnet_client\system_web\2_0_50727
Copy the C:\inetpub\wwwroot\aspnet_client folder to physical path of My Rocking Web Site
Decompiler View
You can see from the decompiled source files outlined below the code location is not configurable. However, the lcoation is configurable with the Enterprise version of Crystal Reports.
// Add to page loadCrystalReportViewer1.HasExportButton=false;CrystalReportViewer1.HasPrintButton=false;privatevoidExportReport(ExportFormatTypepeExportType){//declare a memorystream object that will hold out outputMemoryStreamoStream;//here's the instance of a valid report, one which we have already Load(ed)ReportDocumentcrReport=rptDocument;/**remember that a valid crystal report has to be loaded before you run this code**///clear the response and set Buffer to trueResponse.Clear();Response.Buffer=true;switch(peExportType){caseExportFormatType.RichText:// ...Rich Text (RTF)oStream=(MemoryStream)crReport.ExportToStream(CrystalDecisions.Shared.ExportFormatType.RichText);Response.ContentType="application/rtf";break;caseExportFormatType.PortableDocFormat:// ...Portable Document (PDF)oStream=(MemoryStream)crReport.ExportToStream(ExportFormatType.PortableDocFormat);Response.ContentType="application/pdf";break;caseExportFormatType.WordForWindows:// ...MS Word (DOC)oStream=(MemoryStream)crReport.ExportToStream(ExportFormatType.WordForWindows);Response.ContentType="application/msword";break;caseExportFormatType.Excel:// ...MS Excel (XLS)oStream=(MemoryStream)crReport.ExportToStream(ExportFormatType.Excel);Response.ContentType="application/vnd.ms-excel";break;default://...Portable Document (PDF)oStream=(MemoryStream)crReport.ExportToStream(ExportFormatType.PortableDocFormat);Response.ContentType="application/pdf";break;}try{//write report to the Response streamResponse.BinaryWrite(oStream.ToArray());Response.End();}catch(Exceptionex){Console.WriteLine("ERROR: "+Server.HtmlEncode(ex.Message.ToString()));CxErrorlogFactory.Log("",ex.Source,ex.Message+ex.StackTrace+ex.InnerException);}finally{//clear streamoStream.Flush();oStream.Close();oStream.Dispose();}}protectedvoidbtnExportAsPDF_Click(objectsender,EventArgse){ExportReport(ExportFormatType.PortableDocFormat);}protectedvoidbtnExportAsWord_Click(objectsender,EventArgse){ExportReport(ExportFormatType.WordForWindows);}protectedvoidbtnExportAsExcel_Click(objectsender,EventArgse){ExportReport(ExportFormatType.Excel);}
ReportViewer
12345678910111213141516171819
<tablewidth="600"id="table2"><tr><tdalign="left"width="200"><cc_dxe:ASPxButtonID="btnExportAsPDF"runat="server"Text="Export to PDF"Width="200px"OnClick="btnExportAsPDF_Click"></cc_dxe:ASPxButton>
</td><tdalign="left"width="200"><cc_dxe:ASPxButtonID="btnExportAsWord"runat="server"Text="Export to Word"Width="200px"OnClick="btnExportAsWord_Click"></cc_dxe:ASPxButton>
</td><tdalign="left"width="200"><cc_dxe:ASPxButtonID="btnExportAsExcel"runat="server"Text="Export to Excel"Width="200px"OnClick="btnExportAsExcel_Click"></cc_dxe:ASPxButton>
</td></tr></table>