Configuring your Web.Config file

A Web.Config file in an ASP.NET web application stores global settings such as database connection information, assembly references, and error handling. This file is written in XML, and its root element must always be <configuration>. This is an advanced configuration and is not required.

The following elements are unique to Crystal Reports and may be added to your Web.Config file.

Note

Version numbers may change according to the product that you have.

CrystalImageHandler

The CrystalImageHandler element displays all dynamic images in the CrystalReportViewer control. This setting configures the ASP.NET worker process to redirect requests made to CrystalImageHandler.aspx to an internal only image handler class. If you do not have the CrystalImageHandler setting in your Web.Config file, the images on your website will not show. This element is automatically added to the Web.Config file when you add the CrystalReportViewer control to your website.

  <system.web>
        <httpHandlers>
            <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        </httpHandlers>
  </system.web>

CrystalImageCleaner

The CrystalImageCleaner process automatically deletes dynamically generated images rendered by the CrystalReportViewer control. This setting allows you to set the interval of time between scans of the image directory and the minimum age of the files before they are deleted. This element is automatically added to the Web.Config file when you add the CrystalReportViewer control to your website. This corresponds to the CrystalImageCleaner class.

  • CrystalImageCleaner-Sleep initializes the amount of time in milliseconds that the image cleaner sleeps before scanning and cleaning up image files in the dynamic image directory.
  • CrystalImageCleaner-Age initializes the minimum age in milliseconds of a file before it is deleted.
  • CrystalImageCleaner-AutoStart controls the CrystalImageCleaner process. The image cleaner cleans up the temporary images that are created when viewing a report whose value is set to true.

Note

Only one image cleaner can be started in a single ASP.NET worker process.

  <appSettings>
              <add key="CrystalImageCleaner-AutoStart" value="true" />
              <add key="CrystalImageCleaner-Sleep" value="60000" />
            <add key="CrystalImageCleaner-Age" value="120000" />
  </appSettings>
 

printControl

The printControl element allows you to print the report directly to your local printer. By default, this control is not installed on your local machine and must be downloaded separately. You can download the PrintControl .cab file from the Business Objects technical support website: http://technicalsupport.businessobjects.com/. This setting makes the .cab file visible to your Crystal Reports.NET website. This element needs to be manually added to the Web.Config file of your website.

 
  <configSections>
        <sectionGroup name="businessObjects">
          <sectionGroup name="crystalReports">
            <section name="printControl" type="System.Configuration.NameValueSectionHandler, System, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
          </sectionGroup>
        </sectionGroup>
  </configSections>

  <businessObjects>
        <crystalReports>
          <printControl>
            <add key="url" value="http://localhost/PrintControl.cab" />
          </printControl>
        </crystalReports>
  </businessObjects>

reportMappings

The reportMappings element updates websites created in Visual Studio 2003 that use embedded reports to non-embedded websites when opened in Visual Studio 2005 or later. This setting converts the .dll file created in Visual Studio 2003 to a disk file. Visual Studio 2005 and 2008 do not support embedded websites and you must modify your Web.Config file to ensure that your report is still functional with the newer version of Visual Studio. This element needs to be manually added to the Web.Config file of your website. The reportMappings setting requires an absolute path.

Note

This element is valid for Visual Studio 2005 and Visual Studio 2008 only.

 
  <configSections>
        <sectionGroup name="businessObjects">
          <sectionGroup name="crystalReports">
            <section name="reportMappings" type="CrystalDecisions.Shared.ReportMappingHandler, CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304, Custom=null" />
          </sectionGroup>
        </sectionGroup>
  </configSections>
    
  <businessObjects>
        <crystalReports>
          <reportMappings>
            <add reportName="World Sales Report.rpt" path="C:\Report\World Sales Report.rpt" />
          </reportMappings>
        </crystalReports>
  </businessObjects>

UseBrowserLocale

The UseBrowserLocale element retrieves the language settings in your browser for the CrystalReportViewer control. When set to true, this setting configures the CrystalReportViewer control to observe the browser locale. When set to false, this setting restricts the locale that is displayed page-by-page. This element needs to be manually added to the Web.Config file of your website.

  <configSections>
        <sectionGroup name="businessObjects">
             <sectionGroup name="crystalReports">
            <section name="crystalReportViewer" type="System.Configuration.NameValueSectionHandler" />
             </sectionGroup>
        </sectionGroup>
  </configSections>

  <businessObjects>
        <crystalReportViewer>
            <add key="UseBrowserLocale" value="true" />
        </crystalReportViewer>
  </businessObjects>

serverFileReportManager

The serverFileReportManager element is a web service that enumerates the server files on the server machine. This setting allows you to get a list of objects (folders and reports) from a remote machine. This setting assigns the root of the file directory for the server. In this example, the root is set to c:\inetpub\wwroot. This element needs to be manually added to the Web.Config file of your website.

Note

This corresponds to the serverFileReportManager class.

  <configSections>
        <sectionGroup name="crystalDecisions">
            <section name="serverFileReportManager" type="System.Configuration.NameValueSectionHandler, System, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, Custom=null" />
        </sectionGroup>
  </configSections>

  <crystalDecisions>
        <serverFileReportManager>
            <add key="rootDirectory" value="c:\inetpub\wwwroot" />
        </serverFileReportManager>
  </crystalDecisions>

globalResourcePath

The globalResourcePath element is the reference to the file directory path for global resources. This file directory contains your custom language resources in a central location and can be shared across multiple web applications. This setting allows you to access the global resources in a specific website. In CrystalReports.NET, the default resource files are not shipped with the product install, but can be downloaded from the Business Objects technical support website: http://technicalsupport.businessobjects.com/. This element needs to be manually added to the Web.Config file of your website.

  <appSettings>
          <add key="globalResourcePath" value="c:\CrystalReportViewer_resource_files\"/>
  </appSettings>

Sample Web.Config File

<?xml version="1.0"?>
  <configuration>
       <appSettings>
              <add key="CrystalImageCleaner-AutoStart" value="true"/>
            <add key="CrystalImageCleaner-Sleep" value="60000"/>
            <add key="CrystalImageCleaner-Age" value="120000"/>
     </appSettings>
    <connectionStrings/>
    <system.web>
        <compilation debug="true">
                <assemblies>
            <add assembly="CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Shared, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportSource, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Enterprise.Framework, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Enterprise.Desktop.Report, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.CrystalReports.Engine, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.Enterprise.InfoStore, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692FBEA5521E1304"/>
            <add assembly="CrystalDecisions.ReportAppServer.ClientDoc, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
          </assemblies>
        </compilation>
        <authentication mode="Windows"/>
              <httpHandlers>
          <add verb="GET" path="CrystalImageHandler.aspx" type="CrystalDecisions.Web.CrystalImageHandler, CrystalDecisions.Web, Version=10.5.3700.0, Culture=neutral, PublicKeyToken=692fbea5521e1304"/>
        </httpHandlers>
    </system.web>
  </configuration>

See Also