Skip to main content

ReportDesignerConfigurationBuilder.RegisterDataSourceWizardConnectionStringsProvider<T>(Boolean) Method

Registers a custom connection string provider that supplies data connections for the Data Source Wizard.

Namespace: DevExpress.AspNetCore.Reporting

Assembly: DevExpress.AspNetCore.Reporting.v24.1.dll

NuGet Package: DevExpress.AspNetCore.Reporting

Declaration

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

Parameters

Name Type Description
overrideWebConfigConnections Boolean

If true, only the connection name is serialized with the report definition. If false, data connection parameters are serialized with the report data source when the report is passed to the client.

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

How to Use the Method

A connection string provider defines which data connections are available in the Web Report Designer. To create a custom provider, implement the IDataSourceWizardConnectionStringsProvider interface. To use the custom provider in your application, call the RegisterDataSourceWizardConnectionStringsProvider method with the custom provider as a typed parameter:

using DevExpress.DataAccess.ConnectionParameters;
using DevExpress.DataAccess.Native;
using DevExpress.DataAccess.Web;
using System.Collections.Generic;
// ... 

public class MyDataSourceWizardConnectionStringsProvider : IDataSourceWizardConnectionStringsProvider {
    public Dictionary<string, string> GetConnectionDescriptions() {
        // Load a list of connections.
        // ...
    }

    public DataConnectionParametersBase GetDataConnectionParameters(string name) {
      // Return connection parameters for the connection specified by its name.
      // ..
    }
}

Method Details

In the code above, the RegisterDataSourceWizardConnectionStringsProvider method is called with the boolean parameter set to true. In this instance, only the connection name is serialized with report definition. This behavior ensures connection security because no data connection parameters are saved with report layouts. When the Web Document Viewer or the Report Designer’s Preview generates a document, connection parameters are requested from the custom connection string provider.

Note

The built-in connection string provider gets connection information from the appsettings.json file.

If you pass false as the RegisterDataSourceWizardConnectionStringsProvider method parameter, 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 ASP.NET Core data protection service.You can implement a custom data protection mechanism using the ISecureDataConverter or IDataSourceProtectionService interface.

To prevent serialization of data connection parameters, you can alternatively use the technique described in the RegisterDataSourceWizardConnectionStringsProvider<T>() reference topic. It uses a method overload without parameters and allows you to apply the dependency injection pattern.

Dependency Injection

To use dependency injection inside the IDataSourceWizardConnectionStringsProvider service, call the RegisterDataSourceWizardConnectionStringsProvider method without passing the overrideWebConfigConnections parameter. In this situation, data connection settings are saved alongside the report layout.

Security reasons mean you shouldn’t save connection parameters in the report layout. To ensure security, register the IConnectionProviderFactory service. The purpose of that service is creating an instance of the IConnectionProviderService that supplies connection data to Web Reporting components. Move the connection loading logic from the IDataSourceWizardConnectionStringsProvider to the IConnectionProviderService.

For more information, review the following help topic: SQL Database - Update Connections in the End-User Report Designer (ASP.NET Core).

Tip

Use the RegisterDataSourceWizardConfigFileConnectionStringsProvider() method to register a built-in connection string provider. In this instance, the connection strings specified in the project’s appsettings.json file are listed in the SQL Data Source Wizard.

See Also