DefaultWebDocumentViewerContainer.UseFileReportStorage(String) Method
Specifies the path to the file cache storage used to cache the reports from which the Viewer generates documents.
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 report xml files are stored. |
Remarks
To preview a report, the Web Document Viewer component generates a report document. By default, the document is stored in a memory cache. This storage is unreliable because the application pool may be recycled and the document is lost to the Web Document Viewer. To prevent this, implement a file-based document storage using the UseFileDocumentStorage method.
If the report contains interactive features, the document viewer recreates the document using an instance of the report, which is stored in memory by default. Use the UseFileReportStorage method to specify a path to store the serialized report. The Document Viewer loads that report from the file storage to recreate the document when the memory cache is cleared.
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.
You should place a call to the UseFileReportStorage method in the Global.asax
file before the StaticInitialize
method:
using DevExpress.XtraReports.Web.WebDocumentViewer;
// ...
public class Global_asax : System.Web.HttpApplication {
void Application_Start(object sender, EventArgs e) {
// ...
DefaultWebDocumentViewerContainer.UseFileReportStorage(Server.MapPath("~/App_Data/PreviewCache"));
// ...
ASPxReportDesigner.StaticInitialize();
// ...
}
}
The Web Document Viewer uses the file storage specified with the UseFileReportStorage method when a report is loaded with the OpenReport(XtraReport) method. We recommend that you use the OpenReport(String) method overload instead to eliminate the need for an additional file storage. Note that before you pass a string to the OpenReport
method, you should implement the IWebDocumentViewerReportResolver> report name resolution service.
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 clear a cache, use the following code snippet (where “viewer” is a client instance of the Document Viewer). Note that the Garbage Collector does not free memory immediately after it deletes a report.
viewer.close();
For more information, review the following help topic: Web Document Viewer Cache Management.