Skip to main content

ASP.NET Core Security Considerations

  • 7 minutes to read

This document details important security considerations when deploying an ASP.NET Core Dashboard application.

Data Connection Security

The Web Dashboard requires data connection parameters to obtain data from certain data sources or to display existing dashboards (for instance, created in WinForms Designer or in code):

  • Users can create data sources based on predefined data connections in the UI, or you can add predefined data sources in code. For example, DashboardSqlDataSource and DashboardOlapDataSource can require a user name and password.
  • The Web Dashboard control automatically checks whether dashboards contain data connection parameters. If so, the dashboard will not be loaded and an error message will be displayed. In this instance, remove all connection parameters from the dashboard definition and only retain the connection name.

The Web Dashboard control does not expose connection strings from appsettings.json when used Designer mode. You need to use a data connection string provider to avoid data leaks and pass connection parameters safely. You can use a predefined data connection string provider or implement a custom provider:

Use the predefined provider

DashboardConnectionStringsProvider is a predefined implementation of the data connection string provider. This provider makes all connection strings in appsettings.json available and allows users to create new data sources based on connection strings from the configuration file.

Pass the DashboardConnectionStringsProvider instance as the DashboardConfigurator.SetConnectionStringsProvider method’s parameter to use this provider:

using DevExpress.DataAccess.Web;
// ...
services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
    DashboardConfigurator configurator = new DashboardConfigurator();
    configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(Configuration));
    return configurator;
Implement a custom provider
A custom data connection provider allows you to add custom logic. For example, you can read connection strings from a custom source or manage connection strings between users. To use a custom connection provider, implement the IDataSourceWizardConnectionStringsProvider interface and pass the new provider to the DashboardConfigurator.SetConnectionStringsProvider method call. See the following topic for details: Register Default Data Connections.

While not recommended, you can use the DashboardConfigurator.PassCredentials property to disable connection parameter validation. This property was introduced to prevent you from passing confidential information to the client. If this property is enabled, the dashboard is displayed regardless of user credential information. Once again, do not enable this property in production apps.

Database Security

Enable Custom SQL

The Data Source Wizard initially allows users to construct SQL queries only in the built-in Query Builder. Queries constructed in the Query Builder can be considered safe because they only contain a SELECT statement.

Users cannot edit SQL queries in the Query Builder (the default setting). Refer to the following article to enable SQL query editing using the UI: Custom SQL Queries. Custom SQL queries are validated before execution. Make certain to apply secure SQL validation to prevent harmful request execution.

We recommend that you utilize the access control functionality of your database management system to achieve the highest level of database security.

Restrict Access to Unauthorized Assemblies

You cannot load custom assemblies that can be referenced by Entity Framework data sources (DashboardEFDataSource) (the default setting).

To permit a user to load a specific assembly, handle the DashboardConfigurator.CustomAssemblyLoading event. An unauthorized attempt to load a custom assembly will result in a CustomAssemblyLoadingProhibitedException.

Restrict Access to External Data Resources

The Dashboard Control obtains data from resources stored on the disk or on the Internet. We recommend that you specify access settings for data resources (Excel, Extract, and JSON data sources).

You can read files from any directory by default. To protect your application, use the AccessSettings class to explicitly specify where data sources can be read from. To accomplish this, configure rules in the DataResources property to restrict file system access to specified folders. You can call the SetRules(IAccessRule[]) method when your application starts to specify rules before a dashboard control sets its rules. The SetRules(IAccessRule[]) method can be called only once at application startup. Otherwise, the method will raise an exception. Alternatively, you can use the TrySetRules(IAccessRule[]) method, which does not raise an exception.

Data Source Access Rights

The example below shows how to configure the Dashboard control so that it loads data in a multi-user environment. You can identify a user in the current session and select which underlying data source is available for this user.

View Example

Database Schema Customization

A custom database schema provider allows you to restrict access to tables, views, stored procedures, and columns in the Query Builder based on specific conditions (such as user role or connection settings). For more information on database schema providers, refer to the following article: Implement a Custom Database Schema.

The following example implements a custom database schema provider for SQL Data Sources in ASP.NET Core:

View Example

Dashboard Parameters Security

A user can obtain sensitive information from dashboard parameters. Encode parameter values wherever/whenever possible. Do not store sensitive/unencrypted information within dashboard parameters.

Working Mode Access Rights

The Web Dashboard can function as a designer or viewer. The following modes are available:

The Web Dashboard works as a designer and allows users to create, edit, and save dashboards. In this mode, the control loads the extensions required to design dashboards. Users can access the Data Source Wizard, preview underlying data, and modify dashboards from storage. Requests from the dashboard backend server can be sent to third-party resources. A user can also switch the control to Viewer mode. This is the default mode.
The Web Dashboard works as a viewer and displays dashboards to users. In this mode, the control also loads the extensions required to design dashboards. A user can switch the control to Designer mode as needs dictate.
The Web Dashboard does not load extensions required to design dashboards. Users cannot switch to Designer or Viewer modes on the client.


The working mode does not influence the server settings. Initially, the server works at the ClientTrustLevel.Full trust level. Verify the trust level and specify which actions a client can initiate on the server.

You can use one of the following methods to prevent inadvertent or unauthorized modifications to dashboards stored on the server:

Restricted mode affects the Web Dashboard in the following manner:

  • Only dashboards stored in dashboard storage can be processed on the client. Designer mode does not work.

  • Calling the IEditableDashboardStorage.AddDashboard and IDashboardStorage.SaveDashboard methods leads to an exception.

  • Information about data sources contained in a dashboard xml definition is not passed to the client when you request a dashboard XML file.

Dashboard Access Rights

The Web Dashboard allows users to open, modify, and create new dashboards. If you want to specify different access rights for different users, create custom dashboard storage (IDashboardStorage or IEditableDashboardStorage), and add verification procedures in the implemented class.

View Example: ASP.NET Core - How to implement multi-tenant Dashboard architecture

XSS Security

HTML-injection is a common XSS attack type. To prevent this type of injection, make certain to enable the EncodeHtml property:

Prevent Cross-Site Request Forgery (CSRF)

Cross-site request forgery (also known as XSRF or CSRF) is a form of malicious website exploit wherein unauthorized commands are submitted from a trusted user. To prevent cross-site request forgery (CSRF) attacks on your web application, use a custom dashboard controller and apply anti-forgery request validation. Review the following example for implementation details:

View Example

Cache Security

When Web Dashboard executes data-related operations in client data processing mode, data from a data source can be cached. The Web Dashboard control uses a single cache. The use of separate DashboardConfigurator instances does not create separate caches. Create a custom parameter to specify a different cache for each user.

The following example shows how to use a custom parameter for this purpose:

View Example

// Configure user-specific data caching
private void DashboardConfigurator_CustomParameters(object sender, CustomParametersWebEventArgs e) {
    var userId = contextAccessor.HttpContext.Session.GetString("CurrentUser").GetHashCode();
    e.Parameters.Add(new Parameter("UserId", typeof(string), userId));

See the following topic for more information: Dashboard Backend - Manage an In-Memory Data Cache.

See Also