Back to Devexpress

Register JSON Data Connections (ASP.NET MVC)

xtrareports-401654-web-reporting-asp-net-mvc-reporting-end-user-report-designer-in-asp-net-mvc-applications-bind-to-data-register-json-data-connections.md

latest4.6 KB
Original Source

Register JSON Data Connections (ASP.NET MVC)

  • Nov 07, 2025
  • 5 minutes to read

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.

Use the Application Configuration File

Follow the steps below to use connection strings from the application configuration file (Web.config):

  1. Add data connections to the application’s configuration file (Web.config).

  2. Register the connection string provider. Call the static DefaultReportDesignerContainer.RegisterDataSourceWizardConfigFileJsonConnectionStringsProvider method at application startup.

Implement a Custom Connection String Provider

A custom connection provider allows you to manage JSON connections accessible to users:

  • Modify connections at runtime (for example, depending on the user)
  • Allow users to create new connections
  • Validate connections and keep them in a separate storage
  • Store credentials securely

Tip

To review a sample JSON connection provider and storage implementation, use the DevExpress template to create an ASP.NET MVC Reporting application and view the following files:

  • C#

  • VB.NET

  • 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 MVC Reporting App with a Report Designer.

To use a custom JSON connection provider, follow the steps below:

  1. Create a class that implements the IDataSourceWizardJsonConnectionStorage interface. The code snippet below stores connections in a session.

  2. Create a new class (CustomJsonDataConnectionProviderFactory in this example) that implements the IJsonDataConnectionProviderFactory interface.

  3. 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

Use a Custom Database Schema

Register Predefined Data Sources (ASP.NET MVC)

Register SQL Data Connections in ASP.NET MVC Reporting