ASP.NET Core MVC Server-Side Configuration

The Web Dashboard requires configuring various server-side options before using it: preparing dashboard storage, registering predefined data sources, etc. You can use different approaches to utilize a server-side API depending on the selected platform (ASP.NET or ASP.NET MVC).

Register Default Controller

Call the MvcBuilderExtension.AddDefaultDashboardController method to register a default controller and add a default dashboard configurator. The code snippet below shows how to add the required code to the Startup.cs file.

using DevExpress.DashboardAspNetCore;
using DevExpress.AspNetCore;
using DevExpress.DashboardWeb;

// ...

public void ConfigureServices(IServiceCollection services) {
    services
        .AddMvc()
        .AddDefaultDashboardController(configurator => { });
    // ... 
}

Note that you need to define a dashboard storage and connection strings provider in a dashboard configurator. See the corresponding sections below for more information.

Add Third-Party and DevExtreme Middleware

Use the MvcServiceCollectionExtensions.AddDevExpressControls method to provide the Third-Party and DevExtreme middleware that is assembled into an application pipeline to handle requests and responses. The code snippet below shows how to add the required code to the Startup.cs file.

using DevExpress.AspNetCore;

// ...

public void ConfigureServices(IServiceCollection services) {
    // ... 
    services.AddDevExpressControls(settings => settings.Resources = ResourcesType.ThirdParty | ResourcesType.DevExtreme);
}

Register DevExpress Middleware

Call the ApplicationBuilderExtensions.UseDevExpressControls method to register the DevExpress middleware. The code snippet below shows how to add the required code to the Startup.cs file.

using DevExpress.AspNetCore;

// ...

public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
    // ... 
    app.UseStaticFiles();
    app.UseDevExpressControls();
    // ... 
}

Map Dashboard Route

Call the RouteBuilderExtension.MapDashboardRoute method to extend a object for routing within a web application containing the ASP.NET Core MVC Dashboard. The code snippet below shows how to add the required code to the Startup.cs file.

using DevExpress.DashboardAspNetCore;

// ...

public void Configure(IApplicationBuilder app, IHostingEnvironment env) {
    /// ...
    app.UseMvc(routes => {
        routes.MapDashboardRoute("api/dashboard");
        routes.MapRoute(
            name: "default",
            template: "{controller=Home}/{action=Index}/{id?}");
    });
}

The api/dashboard prefix is used to handle requests from the client-side DashboardControl.

Prepare a Dashboard Storage

The Web Dashboard requires creating a special dashboard storage. End-users can save new dashboards to this storage and open existing dashboards.

See Preparing a Dashboard Storage for details on how to create a dashboard storage for the ASP.NET MVC server side.

Register Default Data Sources

See Register Default Data Sources for details on how to supply end-users with a default data source set.

Register Default Data Connections

See Register Default Data Connections to learn how to provide a Web Dashboard with a predefined data connection set. The Dashboard Data Source Wizard displays these connections for end-users when creating new data sources.

See Also