Skip to main content
A newer version of this page is available. .

MvcBuilderExtension.AddDefaultDashboardController(IMvcBuilder, Action<DashboardConfigurator>) Method

Adds the dashboard controller and provides access to the DashboardConfigurator settings.

Namespace: DevExpress.DashboardAspNetCore

Assembly: DevExpress.Dashboard.v20.2.AspNetCore.dll

NuGet Package: DevExpress.AspNetCore.Dashboard

Declaration

public static IMvcBuilder AddDefaultDashboardController(
    this IMvcBuilder mvcBuilder,
    Action<DashboardConfigurator> configure
)

Parameters

Name Type Description
mvcBuilder IMvcBuilder

An interface for configuring MVC services.

configure Action<DashboardConfigurator>

A delegate that provides access to the DashboardConfigurator settings.

Returns

Type Description
IMvcBuilder

An interface for configuring MVC services.

Remarks

Use the AddDefaultDashboardController method to add the dashboard controller and register a default DashboardConfigurator instance as a singleton lifetime service. This method also allows you to configure dashboard storage, predefined data sources, and other DashboardConfigurator server-side settings:

using DevExpress.DashboardAspNetCore;
using Microsoft.Extensions.DependencyInjection;

// ...

public void ConfigureServices(IServiceCollection services) {
    services
        .AddMvc()
        .AddDefaultDashboardController((configurator)  => {
            // Configure dashboard server-side settings like dashboard storage, predefined data sources, etc.
        });
}

If you derive the DashboardConfigurator class and implement custom logic, use the AddSingleton method instead AddDefaultDashboardConfigurator to register the derived class as a singleton service. For example, you create the MultiTenantDashboardConfigurator class that is derived from DashboardConfigurator. Use the following code to add a singleton service of the MultiTenantDashboardConfigurator type:

View Example: ASP.NET Core Dashboard - How to load different data based on the current user

using DevExpress.DashboardAspNetCore;
using Microsoft.Extensions.DependencyInjection;

// ...

public void ConfigureServices(IServiceCollection services) {
    // ...
    services.AddSingleton<MultiTenantDashboardConfigurator>();
}
See Also