Skip to main content

Register Services in the Report Designer in ASP.NET Core Application

  • 5 minutes to read

You can register custom and/or predefined services to add specific functionality to the Web Report Designer and its built-in Document Preview.

Report Designer’s Services

In the application startup file, use the ServiceCollectionServiceExtensions and ReportDesignerConfigurationBuilder class methods as shown below.

using DevExpress.AspNetCore;
using DevExpress.AspNetCore.Reporting;

var builder = WebApplication.CreateBuilder(args);

builder.Services.ConfigureReportingServices(configurator => {
    configurator.ConfigureReportDesigner(designerConfigurator => {
        designerConfigurator.RegisterDataSourceWizardConnectionStringsProvider<customProvider>();
    });
});

builder.Services.AddSingleton<IDataSourceWizardDBSchemaProviderExFactory, DBSchemaProviderExFactory>();

var app = builder.Build();

See the following topic for more information: Introduction to Dependency Injection in ASP.NET Core.

Custom Services

The following table lists the services you can implement and register in the Report Designer:

Service

Description

Registration Methods

IDataSourceWizardConnectionStringsProvider

Enables you to manage data connections for the Data Source Wizard.

RegisterDataSourceWizardConnectionStringsProvider<T>

RegisterDataSourceWizardConfigFileConnectionStringsProvider (to use the data source connections from the application’s configuration file).

ISecureDataConverter

Implements a custom encryption mechanism for string data.

ServiceCollectionServiceExtensions class methods

IDataSourceProtectionService

Allows you to implement a custom encryption mechanism to store data source connection strings on the client.

ServiceCollectionServiceExtensions class methods

IDataSourceWizardDBSchemaProviderExFactory

Allows you to customize the database schema.

ServiceCollectionServiceExtensions class methods

ISqlDataSourceWizardCustomizationService

Allows you to customize the Data Source Wizard.

RegisterSqlDataSourceWizardCustomizationService<T>

IReportDesignerExceptionHandler

Enables you to handle server-side errors in the Report Designer.

ServiceCollectionServiceExtensions class methods

PreviewReportCustomizationService

Enables you to customize the current report when the Report Designer is about to be switched to the Preview tab.

ServiceCollectionServiceExtensions class methods

IObjectDataSourceWizardTypeProvider

Returns an array of types that should be listed in the Report Wizard and Data Source Wizard. Users can select one of these types to supply data to reports.
See the following topic for more information: Business Object - Register Types.

RegisterObjectDataSourceWizardTypeProvider<T>()

IObjectDataSourceConstructorFilterService

Generates a list of type constructors. Users can select one of these constructors in the Report Wizard or Data Source Wizard to create an object data source.
See the following topic for more information: Business Object - Register Types.

RegisterObjectDataSourceConstructorFilterService<T>()

IObjectDataSourceMemberFilterService

Generates a list of type members. Users can select one of these members in the Report Wizard or Data Source Wizard to supply data to reports.
See the following topic for more information: Business Object - Register Types.

RegisterObjectDataSourceMemberFilterService<T>()

ISelectQueryFilterService

A service that allows you to apply row-level filtering to all SELECT queries for the Document Viewer, Report Designer Preview, and Query Builder components. For more information review the following help topic: Multi-Tenant Support (Row Filtering in Shared SQL Database).

ServiceCollectionServiceExtensions class methods

IWizardJsonDataSourceSchemaDiscoveryInterceptor

Allows you to specify the JsonDataSource.SchemaDiscoveryMaxItemCount property value.

ServiceCollectionServiceExtensions class methods

Predefined Services

The table below lists the ReportDesignerConfigurationBuilder‘s methods to register the predefined services that override the default Report Designer behavior:

Method Description
EnableCustomSql Allows the user to edit custom SQL strings in the Data Source Wizard.

Document Viewer’s Services

You can also register services for the Report Designer’s integrated Document Viewer.

In the application startup file, use the ServiceCollectionServiceExtensions and WebDocumentViewerConfigurationBuilder class methods as demonstrated below.

using DevExpress.AspNetCore;
using DevExpress.AspNetCore.Reporting;

var builder = WebApplication.CreateBuilder(args);

builder.Services.ConfigureReportingServices(configurator => {
    configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
        viewerConfigurator.RegisterWebDocumentViewerDrillThroughProcessor<CustomDrillThroughProcessor>();
    });
});

builder.Services.AddSingleton<WebDocumentViewerOperationLogger, MyOperationLogger>();

var app = builder.Build();

Custom Services

The following table lists the services you can implement and register in the Report Designer’s Preview:

Service

Description

Registration Methods

IWebDocumentViewerAuthorizationService

Enables you to implement a custom authorization mechanism.

ServiceCollectionServiceExtensions class methods

IExportingAuthorizationService

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

ServiceCollectionServiceExtensions class methods

WebDocumentViewerOperationLogger

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

ServiceCollectionServiceExtensions class methods

IWebDocumentViewerDrillThroughProcessor

Addsdrill-through functionality to web reports.

WebDocumentViewerConfigurationBuilder.RegisterWebDocumentViewerDrillThroughProcessor

IWebDocumentViewerReportResolver

Resolves reports to display in the Web Document Viewer. Does not operate in asynchronous mode.

ServiceCollectionServiceExtensions class methods

DocumentOperationService

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

ServiceCollectionServiceExtensions class 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 methods

IWebDocumentViewerExportResultUriGenerator

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

ServiceCollectionServiceExtensions class methods

StorageCleanerSettings

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

ServiceCollectionServiceExtensions class methods

CacheCleanerSettings

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

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.

Report Storage Extension

Create a descendant from the ReportStorageWebExtension class to define how reports should be stored on your application’s server side. Use the static ReportStorageWebExtension.RegisterExtensionGlobal method in the application startup file to register your storage.

using DevExpress.XtraReports.Web.Extensions;

var builder = WebApplication.CreateBuilder(args);

ReportStorageWebExtension.RegisterExtensionGlobal(new MyReportStorageWebExtension());   

var app = builder.Build();