Skip to main content
A newer version of this page is available. .

WebDocumentViewerConfigurationBuilder.UseFileReportStorage(String) Method

Specifies a path for the report’s file storage.

Namespace: DevExpress.AspNetCore.Reporting

Assembly: DevExpress.AspNetCore.Reporting.v18.2.dll

Declaration

public WebDocumentViewerConfigurationBuilder UseFileReportStorage(
    string workingDirectory
)

Parameters

Name Type Description
workingDirectory String

Specifies a path to the directory where report xml should be stored.

Returns

Type Description
WebDocumentViewerConfigurationBuilder

A WebDocumentViewerConfigurationBuilder that can be used to further configure the Web Document Viewer services.

Remarks

To display a report from the Web Report Designer, the Web Document Viewer generates a report document. By default, documents are stored in a memory cache. This is not a stable storage because the application pool can be recycled when the memory usage reaches a specified limit, idle session closes or a scheduled cache cleaning runs. This all leads to the document’s deletion from the memory cache and the inability of the Document Viewer to display the document. To avoid this, provide a file storage for documents using the UseFileDocumentStorage method.

If a report includes interactive features, the Document Viewer recreates the document using the report instance that is stored in memory by default. Use the UseFileReportStorage method to specify a path to the directory to which the result of report xml serialization will be saved and which the Document Viewer will use to recreate the document when the memory cache is empty.

You can specify the InterProcess synchronization mode for the file storage if you use Web Farms or Garden (by default, the InterThread mode is set). For this purpose, call the UseFileReportStorage(String, StorageSynchronizationMode) method overload.

The following code demonstrates how to use the UseFileReportStorage method, to specify a file storage for the Document Viewer.

using DevExpress.AspNetCore;
using DevExpress.AspNetCore.Reporting;
//... 

public class Startup {
//... 
    string contentRootPath;
    public Startup(IHostingEnvironment env) {
        contentRootPath = env.ContentRootPath;
        //...
    };
    public void ConfigureServices(IServiceCollection services) {
        services.AddDevExpressControls();
        services.AddMvc(); 

        services.ConfigureReportingServices(configurator => {
            configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
                viewerConfigurator.UseFileReportStorage(System.IO.Path.Combine(contentRootPath, "FileReportStorage"));
            });
        });        
    }
//...    
}

Tip

The file storage that you specify using the UseFileReportStorage method is also used by the Document Viewer when it is invoked by the OpenReport(XtraReport) method. We recommend that you use the OpenReport(String) method overload instead not to provide additional file storage with report xml. Implement the IWebDocumentViewerReportResolver interface to associate the passed string value with a specific XtraReport instance.

According to the time settings specified in the CacheCleanerSettings and StorageCleanerSettings classes, the default cleaner service periodically checks if the cache and file storage contain reports whose lifetime exceeds certain amount of time. If such reports are found, they are deleted. Call the UseEmptyStoragesCleaner() method to register an empty storage cleaner instead of the default one, so that reports are not removed automatically.

To force cache clearing, use the following code (where “viewer” corresponds to the client instance name of the Document Viewer). Note that due to Garbage Collector specifics, disposing of a report does not guarantee immediate memory release.

viewer.close();
See Also