Skip to main content

WebDocumentViewerConfigurationBuilder.UseFileDocumentStorage(String) Method

Enables document file storage and specifies a storage path.

Namespace: DevExpress.AspNetCore.Reporting

Assembly: DevExpress.AspNetCore.Reporting.v24.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. Note that this storage is not stable because the application pool can be recycled for several reasons that include the following:

  • memory usage exceeds a certain limit;
  • idle session timeout;
  • a scheduled cache cleaning procedure runs.

In this situation, the document is deleted from the memory cache and the Document Viewer cannot display the document. To prevent this, call the UseFileDocumentStorage method to enable file storage and specify a file path to the document that the Document Viewer can use when the memory cache is empty.

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 reports from REPX files in the file storage. If the report is not found in the 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 report’s FileStorage or Azure storage.

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 uses the UseFileDocumentStorage method to specify file storage for the Document Viewer.

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

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDevExpressControls();
builder.Services.AddMvc(); 

builder.Services.ConfigureReportingServices(configurator => {
    configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
        viewerConfigurator.UseFileDocumentStorage(System.IO.Path.Combine(builder.Environment.ContentRootPath, "FileDocumentStorage") );
    });
});     

var app = builder.Build();

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