The following example demostrates two approaches on how to handle errors in the ASP.NET MVC Dashboard application:
- How to specify custom text for internal Dashboard errors
- How to throw a custom exception during a server-side processing and display the error in the Dashboard error toast
Both projects in this example override the OnException method. You can also handle the ASPxWebControl.CallbackError event to customize error text. See the following example for details about this approach: ASP.NET Web Forms Dashboard - How to handle errors
- Global.asax.cs (VB: Global.asax.vb)
- CustomDashboardController.cs (VB: CustomDashboardController.vb)
- DashboardConfig.cs (VB: DashboardConfig.vb)
- Index.cshtml VB: Index.vbhtml)
The dashboard in this project contains invalid data connection. This example shows how to override the OnException method in a custom dashboard controller to specify custom text in the exception. The exception occurs when the controller tries to load data.
- Create a custom dashboard controller and override the
OnException
method. You can specify the displayed text depending on whether the application is in development mode. - Specify the created custom controller's name in the view.
- Use the created
CustomDashboard
controller when you map a dashboard route.
How to throw a custom exception during a server-side processing and display the error in the Dashboard error toast
- Global.asax.cs (VB: Global.asax.vb)
- DashboardConfig.cs (VB: DashboardConfig.vb)
- CustomDashboardController.cs (VB: CustomDashboardController.vb)
- Index.cshtml (VB: Index.vbhtml)
This example shows how to throw a custom exception when a controller loads a dashboard and display this exception in the dashboard error toast. The example overrides the OnException method.
- Create a custom dashboard controller and override the
OnException
method. You can specify the displayed text depending on whether the application is in development mode. - Specify the created custom controller's name in the view.
- Use the created
CustomDashboard
controller when you map a dashboard route. - To throw an exception when the control loads a dashboard, create custom dashboard storage and override the
LoadDashboard
method.
(you will be redirected to DevExpress.com to submit your response)