xtrareports-401143-web-reporting-asp-net-webforms-reporting-end-user-report-designer-in-asp-net-web-forms-reporting-bind-to-data-register-json-data-connections.md
This document describes how to provide JSON data connections to the Web Report Designer. The Data Source Wizard displays these connections when users create new JSON data sources.
The Data Source Wizard allows you to create a new JSON data source if a JSON data connection provider is registered in the application. You can register a built-in connection provider or implement and register a custom provider:
Built-in connection providerThe provider obtains connections from the application’s configuration file (Web.config).Custom connection providerThe provider allows you to create connection strings at runtime and use a custom storage to store/load connection strings and credentials.
Important
The JsonDataSource object uses the System.Text.Json library. Install the System.Text.Json NuGet package to work with JSON data sources. For more information, refer to the following section: JsonDataSource - Install the System.Text.Json Package.
Follow the steps below to use connection strings from the application configuration file:
Add data connections to the application’s configuration file (Web.config).
Register the connection string provider. Call the static DefaultReportDesignerContainer.RegisterDataSourceWizardConfigFileJsonConnectionStringsProvider method at application startup.
A custom connection provider allows you to manage JSON connections accessible to users:
Tip
To review a sample JSON connection provider and storage implementation, use DevExpress template to create a Web Forms Reporting application and view the following files:
Services\CustomDataSourceWizardJsonDataConnectionStorage.cs
Services\CustomJsonDataConnectionProviderFactory.cs
Global.asax.cs
Services\CustomDataSourceWizardJsonDataConnectionStorage.vb
Services\CustomJsonDataConnectionProviderFactory.vb
Global.asax.vb
For more information on DevExpress templates, refer to the following help topic: Use DevExpress Visual Studio Templates to Create an ASP.NET Web Forms Reporting App with a Report Designer.
To use a custom JSON connection provider, follow the steps below:
Create a class that implements the IDataSourceWizardJsonConnectionStorage interface. The code snippet below stores connections in a session.
Create a new class (CustomJsonDataConnectionProviderFactory in this example) that implements the IJsonDataConnectionProviderFactory interface.
Register services at application startup:
After you register a custom JSON connection provider, you can do the following:
Use an existing connection to create a new JSON data source:
Create a new JSON connection:
See Also
Register SQL Data Connections in ASP.NET Web Forms Reporting