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

WebDocumentViewerConfigurationBuilder.UseFileDocumentStorage(String) Method

Enables document file storage and specifies a storage path.

Namespace: DevExpress.AspNetCore.Reporting

Assembly: DevExpress.AspNetCore.Reporting.v19.1.dll

NuGet Package: DevExpress.AspNetCore.Reporting

Declaration

public WebDocumentViewerConfigurationBuilder UseFileDocumentStorage(
    string workingDirectory
)

Parameters

Name Type Description
workingDirectory String

Specifies a path to store documents.

Returns

Type Description
WebDocumentViewerConfigurationBuilder

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

Remarks

To display a report created in the Web Report Designer, the Web Document Viewer generates a document in PRNX format. Documents are stored in a memory cache. This is not a stable storage because the application pool can be recycled when the memory usage exceeds a certain limit. In this situation, the scheduled cache cleaning procedure starts. The procedure deletes the document from the memory cache and the Document Viewer cannot display the document. To prevent this, call the UseFileDocumentStorage method to enable file storage.

If a report includes interactive features, the Document Viewer re-creates the document from the in-memory report instance. When the memory cache is empty, the Document Viewer can instantiate the reports from REPX files in the file storage. If the report is not found in cache and it is previously opened by a unique report name, the Document Viewer attempts to re-open it by its unique name. If an attempt fails, the Document Viewer queries the FileStorage or Azure storage for the report.

Call the UseFileReportStorage method to enable file storage and specify a path to the REPX files.

If you use Web Farms or Garden, switch to the InterProcess synchronization mode (the default mode is InterThread). For this, call the WebDocumentViewerConfigurationBuilder.UseFileDocumentStorage method with the StorageSynchronizationMode.InterProcess parameter.

The following code demonstrates how to use the UseFileDocumentStorage method, to specify 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.UseFileDocumentStorage(System.IO.Path.Combine(contentRootPath, "FileDocumentStorage") );
            });
        });        
    }
//...    
}

Tip

If you call the ASPxWebDocumentViewer.OpenReport method with the XtraReport parameter, the viewer creates a copy of the report with a unique identifier. When the method is called frequently (in the PageLoad event), it may consume too much memory to store report copies. To solve the problem, use the OpenReport method with the System.String parameter and implement the IWebDocumentViewerReportResolver interface to associate the parameter’s string value with a single report instance.

The cleaner service periodically searches the cache and file storage for expired documents/exported documents/reports and deletes them. You can use the CacheCleanerSettings and StorageCleanerSettings to specify check interval and expiration time settings. To prevent expired documents from being deleted, call the UseEmptyStoragesCleaner() method to register an empty storage cleaner.

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

viewer.close();
See Also