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 |
---|---|---|
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). | |
Implements a custom encryption mechanism for string data. | ServiceCollectionServiceExtensions class methods | |
Allows you to implement a custom encryption mechanism to store data source connection strings on the client. | ServiceCollectionServiceExtensions class methods | |
Allows you to customize the database schema. | ServiceCollectionServiceExtensions class methods | |
Allows you to customize the Data Source Wizard. | ||
Enables you to handle server-side errors in the Report Designer. | ServiceCollectionServiceExtensions class methods | |
Enables you to customize the current report when the Report Designer is about to be switched to the Preview tab. | ServiceCollectionServiceExtensions class methods | |
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. | ||
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. | ||
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. | ||
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 | |
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 |
---|---|---|
Enables you to implement a custom authorization mechanism. | ServiceCollectionServiceExtensions class methods | |
Allows you to implement a custom authorization mechanism for exported documents. | ServiceCollectionServiceExtensions class methods | |
Enables you to log events when the Web Document Viewer processes reports and generated documents. | ServiceCollectionServiceExtensions class methods | |
Addsdrill-through functionality to web reports. | WebDocumentViewerConfigurationBuilder.RegisterWebDocumentViewerDrillThroughProcessor | |
Resolves reports to display in the Web Document Viewer. Does not operate in asynchronous mode. | 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 | |
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 | |
Enables you to specify time settings to clean a storage to store documents and reports. | ServiceCollectionServiceExtensions class methods | |
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();