|
4 | 4 | [](https://docs.devexpress.com/GeneralInformation/403183) |
5 | 5 | <!-- default badges end --> |
6 | 6 |
|
7 | | -# Dashboard for MVC - How to create a custom dashboard controller |
| 7 | +# Dashboard for MVC - How to Create a Restricted Dashboard Controller |
8 | 8 |
|
9 | | -The example shows how to create a custom dashboard controller for the [Web Dashboard](https://docs.devexpress.com/Dashboard/16977/web-dashboard/aspnet-mvc-dashboard-extension) in an ASP.NET MVC application. |
| 9 | +You can do one of the following to prevent inadvertent or unauthorized dashboard modifications and protect dashboards stored on a server: |
10 | 10 |
|
11 | | -Inherit the [DashboardController](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.DashboardController) class to create a custom dashboard controller. Pass its name to the [RouteCollectionExtension.MapDashboardRoute](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.RouteCollectionExtension.MapDashboardRoute(System.Web.Routing.RouteCollection-System.String-System.String-System.String--)) method when you configure routing and to the [DashboardExtensionSettings.ControllerName](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.DashboardExtensionSettings.ControllerName) property when you configure a control on the page. |
| 11 | +- Handle the [DashboardConfigurator.VerifyClientTrustLevel](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.DashboardConfigurator.VerifyClientTrustLevel) event and set [e.ClientTrustLevel](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.VerifyClientTrustLevelEventArgs.ClientTrustLevel) to `Restricted` mode. |
| 12 | +- Derive a custom dashboard controller from [RestrictedDashboardController](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.RestrictedDashboardController) instead of [DashboardController](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.DashboardController). |
12 | 13 |
|
13 | | -In this example, the custom controller name is `DefaultDashboard`. |
| 14 | +The example shows how to create a restricted dashboard controller for the [Web Dashboard](https://docs.devexpress.com/Dashboard/16977/web-dashboard/aspnet-mvc-dashboard-extension) in an ASP.NET MVC application. |
| 15 | + |
| 16 | +## Example Description |
14 | 17 |
|
| 18 | +Inherit the [DashboardController](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.DashboardController) class to create a custom dashboard controller. Add its name (without a `Controller` prefix) to the following places: |
| 19 | +- The [RouteCollectionExtension.MapDashboardRoute](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.RouteCollectionExtension.MapDashboardRoute.overloads) method when you configure routing; |
| 20 | +- The [DashboardExtensionSettings.ControllerName](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.DashboardExtensionSettings.ControllerName) property when you configure a control on the page. |
| 21 | + |
| 22 | +In this example, the custom controller name is `DefaultDashboard`. |
15 | 23 |
|
16 | 24 | <!-- default file list --> |
17 | 25 | ## Files to Look At |
18 | 26 |
|
19 | | -* [DashboardConfig.cs](./CS/MvcCustomController/App_Start/DashboardConfig.cs#L12) |
20 | | -* [DefaultDashboardController.cs](./CS/MvcCustomController/Controllers/DefaultDashboardController.cs) |
21 | | -* [Index.cshtml](./CS/MvcCustomController/Views/Home/Index.cshtml#L8) |
| 27 | +* [DashboardConfig.cs](./CS/MvcCustomController/App_Start/DashboardConfig.cs#L12) (VB: [DashboardConfig.vb](./VB/MvcCustomController/App_Start/DashboardConfig.vb#L10)) |
| 28 | +* [DefaultDashboardController.cs](./CS/MvcCustomController/Controllers/DefaultDashboardController.cs) (VB: [DefaultDashboardController.vb](./VB/MvcCustomController/Controllers/DefaultDashboardController.vb)) |
| 29 | +* [Index.cshtml](./CS/MvcCustomController/Views/Home/Index.cshtml#L7) (VB: [Index.vbhtml](./VB/MvcCustomController/Views/Home/Index.vbhtml#L6)) |
22 | 30 | <!-- default file list end --> |
23 | 31 |
|
24 | 32 | ## Documentation |
25 | 33 |
|
26 | | -- [DashboardController](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.DashboardController) |
| 34 | +- [RestrictedDashboardController](https://docs.devexpress.com/Dashboard/DevExpress.DashboardWeb.Mvc.RestrictedDashboardController) |
| 35 | +- [Security Considerations in Web](https://docs.devexpress.com/Dashboard/118651/designer-and-viewer-applications/web-dashboard/security-considerations) |
27 | 36 |
|
28 | 37 | ## More Examples |
29 | 38 |
|
30 | | -- [Dashboard for ASP.NET Core - How to create a custom dashboard controller](https://github.com/DevExpress-Examples/dashboard-for-asp-net-core-custom-dashboard-controller) |
| 39 | +- [Dashboard for ASP.NET Core - How to create a restricted dashboard controller](https://github.com/DevExpress-Examples/asp-net-core-dashboard-restricted-controller) |
31 | 40 | - [Dashboard for MVC - How to use separate server-side settings for different views](https://github.com/DevExpress-Examples/dashboard-for-mvc-use-separate-server-side-settings-for-different-views) |
32 | 41 | - [Dashboard for MVC - How to implement multi-tenant Dashboard architecture](https://github.com/DevExpress-Examples/DashboardUserBasedMVC) |
33 | 42 | - [Dashboard for MVC - How to load different data based on the current user](https://github.com/DevExpress-Examples/DashboardDifferentUserDataMVC) |
0 commit comments