The requested page is not available for the requested platform. You are viewing the content for Default platform.

Register Services in the Document Viewer

  • 2 min 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.

Custom Services

The following table lists the services you can implement and register in the Document Viewer:

Service

Description

Registration Methods

IWebDocumentViewerAuthorizationService

Enables you to implement a custom authorization mechanism.

ServiceCollectionServiceExtensions class's methods

IExportingAuthorizationService

Allows you to provide a custom authorization mechanism for exported documents.

ServiceCollectionServiceExtensions class's methods

WebDocumentViewerOperationLogger

Enables you to log events when the Web Document Viewer processes reports and generated documents.

ServiceCollectionServiceExtensions class's methods

IWebDocumentViewerDrillThroughProcessor

Provides drill-through functionality to web reports.

WebDocumentViewerConfigurationBuilder.RegisterWebDocumentViewerDrillThroughProcessor

IWebDocumentViewerReportResolver

Resolves reports to display in the Web Document Viewer.

ServiceCollectionServiceExtensions class's methods

DocumentOperationService

Enables you to perform custom operations with a Document Viewer's currently opened document.

ServiceCollectionServiceExtensions class's methods

IConnectionProviderFactory

Allows you to restore a data connection on a report's deserialization.

WebDocumentViewerConfigurationBuilder.RegisterConnectionProviderFactory

IWebDocumentViewerExceptionHandler

Enables you to handle server-side errors in the Web Document Viewer.

ServiceCollectionServiceExtensions class's methods

IWebDocumentViewerExportResultUriGenerator

Allows you to override the default URI that a browser uses to get an export result.

ServiceCollectionServiceExtensions class's methods

StorageCleanerSettings

Enables you to provide time settings to clean a storage to store documents and reports.

ServiceCollectionServiceExtensions class's methods

CacheCleanerSettings

Enables you to provide time settings to clean a cache to store documents and reports.

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.