Register Services in the Document Viewer in ASP.NET Core Application
- 3 minutes to read
You can register custom and/or predefined services to provide specific functionality to the Web Document Viewer.
In the Startup.ConfigureServices method, use the ServiceCollectionServiceExtensions and WebDocumentViewerConfigurationBuilder classes’ methods as shown below.
public void ConfigureServices(IServiceCollection services) {
// ...
services.ConfigureReportingServices(configurator => {
configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
viewerConfigurator.RegisterWebDocumentViewerDrillThroughProcessor<CustomDrillThroughProcessor>();
});
});
services.AddSingleton<WebDocumentViewerOperationLogger, MyOperationLogger>();
}
See Introduction to Dependency Injection in ASP.NET Core for more information.
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 Open a Report in ASP.NET Core Application help topic for more information.
Service | Description | Registration Methods |
---|---|---|
Resolves reports to display in the Web Document Viewer. | ServiceCollectionServiceExtensions class’s methods | |
Returns a CachedReportSourceWeb object associated with the specified report. | ServiceCollectionServiceExtensions class’s methods | |
Returns a CachedReportSourceWeb object associated with the specified report, asynchronously. | ServiceCollectionServiceExtensions class’s methods; call the ReportingConfigurationBuilder.UseAsyncEngine method to enable asynchronous mode | |
Allows you to implement a service that resolves a report unique name (report URL) to a report instance. | ServiceCollectionServiceExtensions class’s methods | |
Allows you to implement a service that asynchronously resolves a report unique name (report URL) to a report instance. | ServiceCollectionServiceExtensions class’s 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 provide time settings to clean a cache to store documents and reports. | ServiceCollectionServiceExtensions class’s methods | |
Enables you to perform custom operations with a Document Viewer’s currently opened document. | ServiceCollectionServiceExtensions class’s 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’s methods | |
Provides drill-through functionality to web reports. | WebDocumentViewerConfigurationBuilder.RegisterWebDocumentViewerDrillThroughProcessor | |
Enables you to handle server-side errors in the Web Document Viewer. | ServiceCollectionServiceExtensions class’s methods | |
Allows you to override the default URI that a browser uses to get an export result. | ServiceCollectionServiceExtensions class’s methods | |
Allows you to override the default URI that a browser uses to get an export result, asynchronously. | ServiceCollectionServiceExtensions class’s methods; call the ReportingConfigurationBuilder.UseAsyncEngine method to enable asynchronous mode | |
Enables you to provide time settings to clean a storage to store documents and reports. | ServiceCollectionServiceExtensions class’s methods | |
Enables you to log events when the Web Document Viewer processes reports and generated documents. | ServiceCollectionServiceExtensions class’s 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 a service that is used to clean the report and document storage with an empty service to avoide automatic cleaning of this storage. |
EnablePassingExportOptionsPasswordsToClient | Enables passing PDF/Excel passwords specified in the Report Designer to the Web Document Viewer. |
Logger Service
Use the LoggerService class to handle exceptions that occur on the server side and log other document-related operations and information messages. Use the LoggerService.Initialize method at the application startup to register a custom logger instance.