Back to Devexpress

Register MongoDB Data Connections (ASP.NET MVC)

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

latest2.6 KB
Original Source

Register MongoDB Data Connections (ASP.NET MVC)

  • Nov 07, 2025
  • 3 minutes to read

This document describes how to define MongoDB data connections available in the Web Report Designer. The Data Source Wizard displays these connections when users create new MongoDB data sources.

Important

Install the MongoDB.Driver NuGet package to work with MongoDB in the Data Source Wizard.

The Data Source Wizard allows you to create a new MongoDB data source if a MongoDB 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.

Use the Application Configuration File

Follow the steps below to use connection strings from the application configuration file:

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

  2. Register the connection string provider. For this, call the static DefaultReportDesignerContainer.RegisterDataSourceWizardConfigFileMongoDBConnectionStringsProvider method at application startup.

Implement a Custom Connection String Provider

A custom connection provider allows you to manage MongoDB 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

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

  1. Implement the IDataSourceWizardMongoDBConnectionStringsProvider interface. The following code snippet shows a sample implementation:

  2. Call the RegisterDataSourceWizardMongoDBConnectionStringsProvider method at application start to register the custom connection strings provider: