Breaking Change T1018632
Visible to All Users

Web Dashboard - The DashboardController class became abstract

What Changed

ASP.NET Core:

  1. The DevExpress.DashboardAspNetCore.DashboardController class became abstract.
  2. The following overloads of the EndpointRouteBuilderExtension.MapDashboardRoute and RouteBuilderExtension.MapDashboardRoute methods without the controllerName parameter became obsolete and will cause the error:
    • EndpointRouteBuilderExtension.RouteCollectionExtension.MapDashboardRoute(this RouteCollection routes)
    • EndpointRouteBuilderExtension.RouteCollectionExtension.MapDashboardRoute(this RouteCollection routes, string routePrefix)
    • RouteBuilderExtension.MapDashboardRoute(this IRouteBuilder routes)
    • RouteBuilderExtension.MapDashboardRoute(this IRouteBuilder routeBuilder, string routePrefix)
  3. The exception occurs if the ControllerName or DashboardBackendOptionsBuilder.Uri properties are not specified.
  4. The MvcBuilderExtension.AddDefaultDashboardController method became obsolete.

ASP.NET MVC:

  1. The DevExpress.DashboardWeb.Mvc.DashboardController class became abstract.
  2. The following overloads of the RouteCollectionExtension.MapDashboardRoute method without the controllerName parameter became obsolete and will cause the error:
    • DevExpress.DashboardWeb.Mvc.RouteCollectionExtension.MapDashboardRoute(this RouteCollection routes)
    • DevExpress.DashboardWeb.Mvc.RouteCollectionExtension.MapDashboardRoute(this RouteCollection routes, string routePrefix)
  3. The exception occurs if the ControllerName or DashboardBackendOptionsBuilder.Uri properties are not specified.

Reasons for Change

We made the class abstract to reduce possible security issues.

Impact on Existing Apps

Your application will crash if you use the default dashboard controller and call the MapDashboardRoute methods without the controllerName parameter.

Affected Apps

This breaking change will affect your ASP.NET Core application if:

  1. You call the EndpointRouteBuilderExtension.MapDashboardRoute or RouteBuilderExtension.MapDashboardRoute methods without the controllerName parameter.
  2. The ASP.NET Core Dashboard control is used without specifying the ControllerName or Uri properties.

This breaking change will affect your ASP.NET MVC application if:

  1. You call the RouteCollectionExtension.MapDashboardRoute method without the controllerName parameter.
  2. The ASP.NET MVC Dashboard extension is used without specifying the ControllerName or Uri properties.

This breaking change will not affect your application if:

  • You create and use a custom controller (a DashboardController descendant). This custom controller is used in the MapDashboardRoute methods.

How to Update Existing Apps

Applications that use the ASP.NET Core Dashboard Backend (Angular, React, Vue, JavaScript Applications, Blazor)

  1. Add a custom dashboard controller to your backend. Create a new DashboardController descendant and implement the required logic.

    C#
    using DevExpress.DashboardAspNetCore; using DevExpress.DashboardWeb; using Microsoft.AspNetCore.DataProtection; // ... public class DefaultDashboardController : DashboardController { public DefaultDashboardController(DashboardConfigurator configurator, IDataProtectionProvider dataProtectionProvider = null) : base(configurator, dataProtectionProvider) { } }
  2. Pass the created controller's name (DefaultDashboard) to the MapDashboardRoute method.

    .NET Core 3.1 and above:

    C#
    EndpointRouteBuilderExtension.MapDashboardRoute(endpoints, "api/dashboard", "DefaultDashboard");

    .NET Core 2.1:

    C#
    routes.MapDashboardRoute("api/dashboard", "DefaultDashboard");
  3. Get rid of the AddDefaultDashboardController method and use dependency injection instead. Register the DashboardConfigurator as a service based on your requirements. The AddSingleton method registers the DashboardConfigurator service with the same service lifetime as AddDefaultDashboardController. However, we recommend that you use the AddScoped method as it can be used in more cases (for example, security-based scenarios like multi-tenancy dashboards).

    Old:

    C#
    services .AddControllersWithViews() .AddDefaultDashboardController((IServiceProvider serviceProvider) => { // content });

    New:

    C#
    services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => { DashboardConfigurator configurator = new DashboardConfigurator(); // content return configurator; });
  4. If you use the default route (dashboardDesigner) generated from the MapDashboardRoute method overload without parameters, you also need to update the endpoint option of your DashboardComponent on the client based on the value you pass to the MapDashboardRoute method.

ASP.NET Core

  1. Create a new DashboardController descendant and implement the required logic to create a custom dashboard controller.

    C#
    using DevExpress.DashboardAspNetCore; using DevExpress.DashboardWeb; using Microsoft.AspNetCore.DataProtection; ... public class DefaultDashboardController : DashboardController { public DefaultDashboardController(DashboardConfigurator configurator, IDataProtectionProvider dataProtectionProvider = null) : base(configurator, dataProtectionProvider) { } }
  2. Pass the created controller's name (DefaultDashboard) to the MapDashboardRoute method.

    NET Core 3.1 and above:

    C#
    EndpointRouteBuilderExtension.MapDashboardRoute(endpoints, "api/dashboard", "DefaultDashboard");

    NET Core 2.1:

    C#
    routes.MapDashboardRoute("api/dashboard", "DefaultDashboard");
  3. Specify the ControllerName property for all Web Dashboard extensions (Html.DevExpress().Dashboard):

    Razor
    @(Html.DevExpress().Dashboard("ASPNETCoreDashboard") .ControllerName("DefaultDashboard") // ... )
  4. Get rid of the AddDefaultDashboardController method and use dependency injection instead. Register the DashboardConfigurator as a service based on your requirements. The AddSingleton method registers the DashboardConfigurator service with the same service lifetime as AddDefaultDashboardController. However, we recommend that you use the AddScoped method as it can be used in more cases (for example, security-based scenarios like multi-tenancy dashboards).

    Old:

    C#
    services .AddControllersWithViews() .AddDefaultDashboardController((IServiceProvider serviceProvider) => { // content });

    New:

    C#
    services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => { DashboardConfigurator configurator = new DashboardConfigurator(); // content return configurator; });

ASP.NET MVC Extension

  1. Create a new DashboardController descendant and implement the required logic to create a custom dashboard controller.

    C#
    using DevExpress.DashboardWeb.Mvc; public class DefaultDashboardController : DashboardController { // ... }
    Visual Basic
    Imports DevExpress.DashboardWeb.Mvc Public Class DefaultDashboardController Inherits DashboardController ' ... End Class
  2. Pass the created controller's name (DefaultDashboard) to the MapDashboardRoute method.

    C#
    routes.MapDashboardRoute("dashboardControl", "DefaultDashboard");
    Visual Basic
    routes.MapDashboardRoute("dashboardControl", "DefaultDashboard")
  3. Specify the ControllerName property for all Web Dashboard extensions (Html.DevExpress().Dashboard):

    C#:

    Razor
    @Html.DevExpress().Dashboard(settings => { settings.Name = "MVCxDashboard"; settings.ControllerName = "DefaultDashboard"; // ... }).GetHtml()

    Visual Basic:

    Razor
    @Html.DevExpress().Dashboard(Sub(settings) settings.Name = "Dashboard" settings.ControllerName = "DefaultDashboard" ' ... End Sub).GetHtml()

How to Revert to the Previous Behavior

You cannot revert to the previous behavior.

Disclaimer: The information provided on DevExpress.com and affiliated web properties (including the DevExpress Support Center) is provided "as is" without warranty of any kind. Developer Express Inc disclaims all warranties, either express or implied, including the warranties of merchantability and fitness for a particular purpose. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.

Confidential Information: Developer Express Inc does not wish to receive, will not act to procure, nor will it solicit, confidential or proprietary materials and information from you through the DevExpress Support Center or its web properties. Any and all materials or information divulged during chats, email communications, online discussions, Support Center tickets, or made available to Developer Express Inc in any manner will be deemed NOT to be confidential by Developer Express Inc. Please refer to the DevExpress.com Website Terms of Use for more information in this regard.