Register Services in the Document Viewer in ASP.NET Core Application
- 3 minutes to read
You can register custom and/or predefined services to add specific functionality to the Web Document Viewer.
In the application startup file, call the ServiceCollectionServiceExtensions and WebDocumentViewerConfigurationBuilder class methods as shown below.
var builder = WebApplication.CreateBuilder(args);
builder.Services.ConfigureReportingServices(configurator => {
configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
viewerConfigurator.RegisterWebDocumentViewerDrillThroughProcessor<CustomDrillThroughProcessor>();
});
});
builder.Services.AddSingleton<WebDocumentViewerOperationLogger, MyOperationLogger>();
var app = builder.Build();
See the following topic for more information: Introduction to Dependency Injection in ASP.NET Core.
Report Name Resolution Services
The table below lists the services you can implement and register in the Document Viewer to resolve a name to a report. Review the following help topic for more information: Open a Report in ASP.NET Core Application.
Service | Description | Registration Methods |
---|---|---|
Resolves reports to display in the Web Document Viewer. Does not operate in asynchronous mode. | ServiceCollectionServiceExtensions class methods | |
Allows you to implement a service that resolves a report unique name (report URL) to a report instance. | ServiceCollectionServiceExtensions class methods | |
Allows you to implement a service that asynchronously resolves a report unique name (report URL) to a report instance. | ServiceCollectionServiceExtensions class methods |
Customization Services
The following table lists the services you can implement and register in the Document Viewer:
Service | Description | Registration Methods |
---|---|---|
Enables you to implement time settings to clean a cache to store documents and reports. | ServiceCollectionServiceExtensions class methods | |
Enables you to perform custom operations with a Document Viewer’s currently opened document. | ServiceCollectionServiceExtensions class methods | |
Allows you to restore a data connection on a report’s deserialization. | WebDocumentViewerConfigurationBuilder.RegisterConnectionProviderFactory | |
Allows you to provide a custom authorization mechanism for exported documents. | ServiceCollectionServiceExtensions class methods | |
Adds drill-through functionality to web reports. | WebDocumentViewerConfigurationBuilder.RegisterWebDocumentViewerDrillThroughProcessor | |
Enables you to handle server-side errors in the Web Document Viewer. | ServiceCollectionServiceExtensions class methods | |
Allows you to override the default URI that a browser uses to get an export result. | ServiceCollectionServiceExtensions class methods | |
Allows you to override the default URI that a browser uses to get an export result asynchronously. | ServiceCollectionServiceExtensions class methods; call the ReportingConfigurationBuilder.UseAsyncEngine method to enable asynchronous mode | |
Enables you to specify time settings to clean a storage to store documents and reports. | ServiceCollectionServiceExtensions class methods | |
Enables you to log events when the Web Document Viewer processes reports and generated documents. | ServiceCollectionServiceExtensions class methods |
Predefined Services
The table below lists the WebDocumentViewerConfigurationBuilder‘s methods to register the predefined services that override the default Document Viewer behavior:
Method | Description |
---|---|
UseFileReportStorage | Specifies a path to the report’s file storage. |
UseFileDocumentStorage | Specifies a path to the report document’s file storage. |
UseFileExportedDocumentStorage | Specifies a path to the exported document’s file storage. |
UseEmptyStoragesCleaner | Replaces the service that is used to clean the report and document storage with an empty service to avoid automatic cleaning of this storage. |
EnablePassingExportOptionsPasswordsToClient | Enables passing PDF/Excel passwords specified in the Report Designer to the Web Document Viewer. |