Dashboard Controller
- 2 minutes to read
A dashboard controller is an MVC Controller descendant. The dashboard controller handles incoming client requests and map them to actions on the server.
Add a Dashboard Controller
Depending on your platform, add a dashboard controller to your application as follows.
ASP.NET Core
Add a new empty DefaultDashboard
controller and inherit the DashboardController class:
using DevExpress.DashboardAspNetCore;
using DevExpress.DashboardWeb;
using Microsoft.AspNetCore.DataProtection;
namespace WebDashboardAspNetCore.Controllers {
public class DefaultDashboardController : DashboardController {
public DefaultDashboardController(DashboardConfigurator configurator, IDataProtectionProvider? dataProtectionProvider = null)
: base(configurator, dataProtectionProvider) {
}
}
}
Add the newly created controller’s name (without the Controller
postfix) to the following places:
- The RouteBuilderExtension.MapDashboardRoute method when you configure routing;
- The DashboardBuilder.ControllerName method when you configure a control on the page.
ASP.NET MVC
Add a new empty DefaultDashboard
controller to the project’s Controllers folder and inherit the DashboardController class:
using DevExpress.DashboardWeb.Mvc;
namespace MvcCustomController {
public class DefaultDashboardController : DashboardController {
}
}
Add the newly created controller’s name (without the Controller
postfix) to the following places:
- The RouteCollectionExtension.MapDashboardRoute method when you configure routing.
- The DashboardExtensionSettings.ControllerName property when you configure a control on the page.
Restrict Access to the Server for Clients
Initially, the server works at the ClientTrustLevel.Full trust level. The working mode does not influence the server settings. Verify the trust level and specify which actions a client can initiate on the server.
You can do one of the following to prevent inadvertent or unauthorized dashboard modifications and protect dashboards stored on a server:
- Handle the DashboardConfigurator.VerifyClientTrustLevel event and set e.ClientTrustLevel to Restricted mode.
- Derive a custom dashboard controller from RestrictedDashboardController instead of
DashboardController
.
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.
The following examples show how to create and use a restricted dashboard controller. In these examples, the custom controller name is DefaultDashboard
.