Skip to main content
All docs
V24.1

Manage Timeout Limit

  • 4 minutes to read

The Web Dashboard has a 300-second time limit to execute a query. When a query timeout expires, the query execution stops and an exception occurs.

You can extend or shorten the time limit in code. The ConnectionOptions.DbCommandTimeout property specifies how many seconds the Web Dashboard waits for a query to execute. The time set in the property is stored in a dashboard definition after a successful connection to a database.

Specify Timeout for a Data Source Created in the UI

The examples below override the dashboard load procedure and set the time limit (up to 600 seconds) for an SQL Data Source query in a dashboard. Use the following code if you create a new data source based on the existing data connection in the UI:

ASP.NET MVC

using System.Web.Routing;
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DashboardWeb.Mvc;
using System.Linq;

namespace MvcDashboardDataSources {
    public static class DashboardConfig {
        public static void RegisterService(RouteCollection routes){
            routes.MapDashboardRoute("dashboardControl", "DefaultDashboard");
            DashboardConfigurator.Default.SetDashboardStorage(new DashboardFileStorageEx("~/App_Data/Dashboards"));
            DashboardConfigurator.Default.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider());
        }
        public class DashboardFileStorageEx : DashboardFileStorage {
            public DashboardFileStorageEx(string workingDirectory) : base(workingDirectory) { }
            protected override System.Xml.Linq.XDocument LoadDashboard(string dashboardID){
                var dashboardXML = base.LoadDashboard(dashboardID);
                Dashboard d = new Dashboard();
                d.LoadFromXDocument(dashboardXML);
                foreach (var ds in d.DataSources.OfType<DashboardSqlDataSource>())
                    ds.ConnectionOptions.CommandTimeout = 600;
                return d.SaveToXDocument();
            }
        }
    }
} 

ASP.NET Core

using DevExpress.DashboardAspNetCore;
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using Microsoft.Extensions.FileProviders;

var builder = WebApplication.CreateBuilder(args);
// ...
builder.Services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
    DashboardConfigurator configurator = new DashboardConfigurator();
    configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(configuration));
    configurator.SetDashboardStorage(new DashboardFileStorageEx(fileProvider.GetFileInfo("Data/Dashboards").PhysicalPath));
    return configurator;
});
// ...
var app = builder.Build();
// ...
app.Run();
// ...
public class DashboardFileStorageEx : DashboardFileStorage {
    public DashboardFileStorageEx(string workingDirectory) : base(workingDirectory) { }
    protected override System.Xml.Linq.XDocument LoadDashboard(string dashboardID) {
        var dashboardXML = base.LoadDashboard(dashboardID);
        Dashboard d = new Dashboard();
        d.LoadFromXDocument(dashboardXML);
        foreach (var ds in d.DataSources.OfType<DashboardSqlDataSource>())
            ds.ConnectionOptions.CommandTimeout = 600;
        return d.SaveToXDocument();
    }
}

Specify Timeout for a Data Source Created in Code

The examples below show how to extend the timeout. The DbCommandTimeout property sets the time limit (up to 600 seconds) for the registered SQL Data Source query. Use the following code if you connect a dashboard to a predefined data source:

ASP.NET MVC

using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using DevExpress.DashboardWeb.Mvc;
using DevExpress.DataAccess.Sql;
using System.Web.Routing;

Namespace MvcDashboardDataSources {
    public static class DashboardConfig {
        public static void RegisterService(RouteCollection routes) {
            routes.MapDashboardRoute("dashboardControl", "DefaultDashboard");
            DashboardConfigurator.Default.SetConnectionStringsProvider(new DevExpress.DataAccess.Web.ConfigFileConnectionStringsProvider());
            DashboardConfigurator.Default.SetDataSourceStorage(CreateDataSourceStorage());     
        }
        public static DataSourceInMemoryStorage CreateDataSourceStorage(){
        DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

        // Registers an SQL data source.
        DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString");
        SelectQuery query = SelectQueryFluentBuilder
            .AddTable("SalesPerson")
            .SelectAllColumnsFromTable()
            .Build("Sales Person");
        sqlDataSource.Queries.Add(query);
        sqlDataSource.ConnectionOptions.DbCommandTimeout = 600;
        dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());
        return dataSourceStorage;
        }
    }
}

ASP.NET Core

using DevExpress.DashboardAspNetCore;
using DevExpress.DashboardCommon;
using DevExpress.DashboardWeb;
using Microsoft.Extensions.FileProviders;

var builder = WebApplication.CreateBuilder(args);

builder.Services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
    DashboardConfigurator configurator = new DashboardConfigurator();
    configurator.SetConnectionStringsProvider(new DashboardConnectionStringsProvider(configuration));
    DataSourceInMemoryStorage dataSourceStorage = new DataSourceInMemoryStorage();

    // Registers an SQL data source.
    DashboardSqlDataSource sqlDataSource = new DashboardSqlDataSource("SQL Data Source", "NWindConnectionString");
    sqlDataSource.DataProcessingMode = DataProcessingMode.Client;
    SelectQuery query = SelectQueryFluentBuilder
        .AddTable("Categories")
        .Join("Products", "CategoryID")
        .SelectAllColumns()
        .Build("Products_Categories");
    sqlDataSource.Queries.Add(query);
    sqlDataSource.ConnectionOptions.DbCommandTimeout = 600;
    dataSourceStorage.RegisterDataSource("sqlDataSource", sqlDataSource.SaveToXml());
    configurator.SetDataSourceStorage(dataSourceStorage);

    return configurator;
});

var app = builder.Build();