Skip to main content

ReportDesignerConfigurationBuilder.RegisterDataSourceWizardConnectionStringsProvider<T>() Method

Registers a custom connection string provider that specifies data connections available to the user in the Data Source Wizard.

Namespace: DevExpress.AspNetCore.Reporting

Assembly: DevExpress.AspNetCore.Reporting.v23.2.dll

NuGet Package: DevExpress.AspNetCore.Reporting

Declaration

public ReportDesignerConfigurationBuilder RegisterDataSourceWizardConnectionStringsProvider<T>()
    where T : class, IDataSourceWizardConnectionStringsProvider

Type Parameters

Name Description
T

A custom connection string provider that implements the IDataSourceWizardConnectionStringsProvider interface.

Returns

Type Description
ReportDesignerConfigurationBuilder

A ReportDesignerConfigurationBuilder that can be used to further configure Report Designer services.

Remarks

A connection string provider defines data connections available in the Web Report Designer.

A custom connection string provider for the Data Source Wizard implements the IDataSourceWizardConnectionStringsProvider interface. To register a custom provider in your application, call the RegisterDataSourceWizardConnectionStringsProvider method with the custom provider as a typed parameter.

Implement and Register the IDataSourceWizardConnectionStringsProvider Service

The following code snippets show service implementation and registration:

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

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddDevExpressControls();
builder.Services.AddMvc(); 

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

var app = builder.Build();

Pass Connection Parameters Securely

Note that data connection parameters are serialized with the report data source when the report is passed to the client. These parameters are encrypted by the default data protection service. For more information about ASP.NET Core data protection services, review the following help topic: Configure ASP.NET Core Data Protection. You can implement a custom data protection mechanism using the ISecureDataConverter or IDataSourceProtectionService interface.

Follow these steps to ensure that the data connection parameters are not saved along with the report layout:

  1. Register the IConnectionProviderFactory service that creates an instance of the IConnectionProviderService service.
  2. Move connection loading code from the IDataSourceWizardConnectionStringsProvider to the IConnectionProviderService.
  3. Modify the GetDataConnectionParameters method in the service implementation to return null.

The following code snippet demonstrates the technique described above and allows you to use dependency injection to pass the IHostingEnvironment service to code that loads connections:

var builder = WebApplication.CreateBuilder(args);

builder.Services.ConfigureReportingServices(configurator => {
    configurator.ConfigureReportDesigner(designerConfigurator => {
        designerConfigurator.RegisterDataSourceWizardConnectionStringsProvider<MyDataSourceWizardConnectionStringsProvider>();
    });
    configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
        viewerConfigurator.RegisterConnectionProviderFactory<MyConnectionProviderFactory>();
    });
});

var app = builder.Build();

Alternatively, you can use another RegisterDataSourceWizardConnectionStringsProvider method overload to avoid saving connection parameters. When the RegisterDataSourceWizardConnectionStringsProvider method is called with the true parameter, only the connection name is serialized into the report definition, rather than the connection parameters.

Use Connection Strings From the Configuration File

The RegisterDataSourceWizardConfigFileConnectionStringsProvider() method enables you to register a predefined connection string provider. In this situation, connection strings from the appsettings.json file are enlisted in the SQL Data Source Wizard.

See Also