DefaultWebDocumentViewerContainer.UseFileDocumentStorage(String) Method
Specifies a path for the report document’s file storage.
Namespace: DevExpress.XtraReports.Web.WebDocumentViewer
Assembly: DevExpress.XtraReports.v24.1.Web.dll
NuGet Package: DevExpress.Web.Reporting.Common
Declaration
Parameters
Name | Type | Description |
---|---|---|
workingDirectory | String | Specifies a path to the directory where documents should be stored. |
Remarks
To display a report, 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 a document. To avoid this, use a file storage for report documents. Call the UseFileDocumentStorage method to specify a path to the directory that the Document Viewer will use to get a document when the memory cache is empty.
The following code demonstrates how to use the UseFileDocumentStorage method, to specify a file storage for the Document Viewer.
using DevExpress.XtraReports.Web.WebDocumentViewer;
//...
DefaultWebDocumentViewerContainer.UseFileDocumentStorage(Server.MapPath("~/App_Data/PreviewCache"));
//...
Use the UseFileDocumentStorage(String, StorageSynchronizationMode) method overload to specify the InterProcess synchronization mode for the file storage if you use Web Farms or Garden. By default, the InterThread mode is set.
Note
If a viewed report includes interactive features, the Document Viewer uses the report’s instance to recreate the document. By default, the report instance is stored in memory. Specify a file storage to avoid problems with application pool recycling. For this purpose, use the UseFileReportStorage method.
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” 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.
viewerModel().close();
Related GitHub Examples
The following code snippets (auto-collected from DevExpress Examples) contain references to the UseFileDocumentStorage(String) method.
Note
The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.