|
1 | | -<!-- default badges list --> |
2 | | - |
3 | | -[](https://supportcenter.devexpress.com/ticket/details/T893871) |
4 | | -[](https://docs.devexpress.com/GeneralInformation/403183) |
5 | | -[](#does-this-example-address-your-development-requirementsobjectives) |
6 | | -<!-- default badges end --> |
7 | | -# Dashboard for MVC - How to handle errors |
8 | | - |
9 | | -The following example demostrates two approaches on how to handle errors in the ASP.NET MVC Dashboard application: |
10 | | - |
11 | | -- [How to specify custom text for internal Dashboard errors](#how-to-specify-custom-text-for-internal-dashboard-errors) |
12 | | -- [How to throw a custom exception during a server-side processing and display the error in the Dashboard error toast](#how-to-throw-a-custom-exception-during-a-server-side-processing-and-display-the-error-in-the-dashboard-error-toast) |
13 | | - |
14 | | -> Both projects in this example override the [OnException](https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.controller.onexception) method. You can also handle the [ASPxWebControl.CallbackError](https://docs.devexpress.com/AspNet/DevExpress.Web.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](https://github.com/DevExpress-Examples/asp-net-web-forms-dashboard-change-default-error-text-callback-error) |
15 | | -
|
16 | | -## How to specify custom text for internal Dashboard errors |
17 | | - |
18 | | -### Files to Review |
19 | | - |
20 | | -* [Global.asax.cs](./CS/MvcCustomTextForInternalDashboardErrors/Global.asax.cs) (VB: [Global.asax.vb](./VB/MvcCustomTextForInternalDashboardErrors/Global.asax.vb)) |
21 | | -* [CustomDashboardController.cs](./CS/MvcCustomTextForInternalDashboardErrors/Controllers/CustomDashboardController.cs) (VB: [CustomDashboardController.vb](./VB/MvcCustomTextForInternalDashboardErrors/Controllers/CustomDashboardController.vb)) |
22 | | -* [DashboardConfig.cs](./CS/MvcCustomTextForInternalDashboardErrors/App_Start/DashboardConfig.cs) (VB: [DashboardConfig.vb](./VB/MvcCustomTextForInternalDashboardErrors/App_Start/DashboardConfig.vb)) |
23 | | -* [Index.cshtml](./CS/MvcCustomTextForInternalDashboardErrors/Views/Default/Index.cshtml) VB: [Index.vbhtml](./VB/MvcCustomTextForInternalDashboardErrors/Views/Default/Index.vbhtml)) |
24 | | - |
25 | | -### Description |
26 | | - |
27 | | -The dashboard in this project contains invalid data connection. This example shows how to override the [OnException](https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.controller.onexception) method in a custom dashboard controller to specify custom text in the exception. The exception occurs when the controller tries to load data. |
28 | | - |
29 | | - |
30 | | - |
31 | | -1. 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. |
32 | | -2. Specify the created custom controller's name in the view. |
33 | | -3. Use the created `CustomDashboard` controller when you map a dashboard route. |
34 | | - |
35 | | -## How to throw a custom exception during a server-side processing and display the error in the Dashboard error toast |
36 | | - |
37 | | -### Files to Review |
38 | | - |
39 | | -* [Global.asax.cs](./CS/MvcThrowCustomExceptionDashboardErrorToast/Global.asax.cs) (VB: [Global.asax.vb](./VB/MvcThrowCustomExceptionDashboardErrorToast/Global.asax.vb)) |
40 | | -* [DashboardConfig.cs](./CS/MvcThrowCustomExceptionDashboardErrorToast/App_Start/DashboardConfig.cs) (VB: [DashboardConfig.vb](./VB/MvcThrowCustomExceptionDashboardErrorToast/App_Start/DashboardConfig.vb)) |
41 | | -* [CustomDashboardController.cs](./CS/MvcThrowCustomExceptionDashboardErrorToast/Controllers/CustomDashboardController.cs) (VB: [CustomDashboardController.vb](./VB/MvcThrowCustomExceptionDashboardErrorToast/Controllers/CustomDashboardController.vb)) |
42 | | -* [Index.cshtml](./CS/MvcThrowCustomExceptionDashboardErrorToast/Views/Default/Index.cshtml) (VB: [Index.vbhtml](./VB/MvcThrowCustomExceptionDashboardErrorToast/Views/Default/Index.vbhtml)) |
43 | | - |
44 | | -### Description |
45 | | - |
46 | | -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](https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.controller.onexception) method. |
47 | | - |
48 | | - |
49 | | - |
50 | | -- 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. |
51 | | -- Specify the created custom controller's name in the view. |
52 | | -- Use the created `CustomDashboard` controller when you map a dashboard route. |
53 | | -- To throw an exception when the control loads a dashboard, create custom dashboard storage and override the `LoadDashboard` method. |
54 | | - |
55 | | -## Documentation |
56 | | - |
57 | | -- [Handle and Log Server-Side Errors in ASP.NET MVC](https://docs.devexpress.com/Dashboard/400025/web-dashboard/integrate-dashboard-component/aspnet-mvc-dashboard-extension/handle-and-log-server-side-errors-in-asp-net-mvc) |
58 | | - |
59 | | -## More Examples |
60 | | - |
61 | | -- [ASP.NET Web Forms Dashboard - How to handle errors](https://github.com/DevExpress-Examples/asp-net-web-forms-dashboard-change-default-error-text-callback-error) |
62 | | -- [ASP.NET Core Dashboard - How to handle errors](https://github.com/DevExpress-Examples/asp-net-core-dashboard-change-default-error-text-exception-filter) |
63 | | -<!-- feedback --> |
64 | | -## Does this example address your development requirements/objectives? |
65 | | - |
66 | | -[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=asp-net-mvc-dashboard-handle-errors&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=asp-net-mvc-dashboard-handle-errors&~~~was_helpful=no) |
67 | | - |
68 | | -(you will be redirected to DevExpress.com to submit your response) |
69 | | -<!-- feedback end --> |
| 1 | +<!-- default badges list --> |
| 2 | + |
| 3 | +[](https://supportcenter.devexpress.com/ticket/details/T893871) |
| 4 | +[](https://docs.devexpress.com/GeneralInformation/403183) |
| 5 | +[](#does-this-example-address-your-development-requirementsobjectives) |
| 6 | +<!-- default badges end --> |
| 7 | +# Dashboard for MVC - How to handle errors |
| 8 | + |
| 9 | +The following example demostrates two approaches on how to handle errors in the ASP.NET MVC Dashboard application: |
| 10 | + |
| 11 | +- [How to specify custom text for internal Dashboard errors](#how-to-specify-custom-text-for-internal-dashboard-errors) |
| 12 | +- [How to throw a custom exception during a server-side processing and display the error in the Dashboard error toast](#how-to-throw-a-custom-exception-during-a-server-side-processing-and-display-the-error-in-the-dashboard-error-toast) |
| 13 | + |
| 14 | +> Both projects in this example override the [OnException](https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.controller.onexception) method. You can also handle the [ASPxWebControl.CallbackError](https://docs.devexpress.com/AspNet/DevExpress.Web.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](https://github.com/DevExpress-Examples/asp-net-web-forms-dashboard-change-default-error-text-callback-error) |
| 15 | +
|
| 16 | +## How to specify custom text for internal Dashboard errors |
| 17 | + |
| 18 | +### Files to Review |
| 19 | + |
| 20 | +* [Global.asax.cs](./CS/MvcCustomTextForInternalDashboardErrors/Global.asax.cs) (VB: [Global.asax.vb](./VB/MvcCustomTextForInternalDashboardErrors/Global.asax.vb)) |
| 21 | +* [CustomDashboardController.cs](./CS/MvcCustomTextForInternalDashboardErrors/Controllers/CustomDashboardController.cs) (VB: [CustomDashboardController.vb](./VB/MvcCustomTextForInternalDashboardErrors/Controllers/CustomDashboardController.vb)) |
| 22 | +* [DashboardConfig.cs](./CS/MvcCustomTextForInternalDashboardErrors/App_Start/DashboardConfig.cs) (VB: [DashboardConfig.vb](./VB/MvcCustomTextForInternalDashboardErrors/App_Start/DashboardConfig.vb)) |
| 23 | +* [Index.cshtml](./CS/MvcCustomTextForInternalDashboardErrors/Views/Default/Index.cshtml) VB: [Index.vbhtml](./VB/MvcCustomTextForInternalDashboardErrors/Views/Default/Index.vbhtml)) |
| 24 | + |
| 25 | +### Description |
| 26 | + |
| 27 | +The dashboard in this project contains invalid data connection. This example shows how to override the [OnException](https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.controller.onexception) method in a custom dashboard controller to specify custom text in the exception. The exception occurs when the controller tries to load data. |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +1. 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. |
| 32 | +2. Specify the created custom controller's name in the view. |
| 33 | +3. Use the created `CustomDashboard` controller when you map a dashboard route. |
| 34 | + |
| 35 | +## How to throw a custom exception during a server-side processing and display the error in the Dashboard error toast |
| 36 | + |
| 37 | +### Files to Review |
| 38 | + |
| 39 | +* [Global.asax.cs](./CS/MvcThrowCustomExceptionDashboardErrorToast/Global.asax.cs) (VB: [Global.asax.vb](./VB/MvcThrowCustomExceptionDashboardErrorToast/Global.asax.vb)) |
| 40 | +* [DashboardConfig.cs](./CS/MvcThrowCustomExceptionDashboardErrorToast/App_Start/DashboardConfig.cs) (VB: [DashboardConfig.vb](./VB/MvcThrowCustomExceptionDashboardErrorToast/App_Start/DashboardConfig.vb)) |
| 41 | +* [CustomDashboardController.cs](./CS/MvcThrowCustomExceptionDashboardErrorToast/Controllers/CustomDashboardController.cs) (VB: [CustomDashboardController.vb](./VB/MvcThrowCustomExceptionDashboardErrorToast/Controllers/CustomDashboardController.vb)) |
| 42 | +* [Index.cshtml](./CS/MvcThrowCustomExceptionDashboardErrorToast/Views/Default/Index.cshtml) (VB: [Index.vbhtml](./VB/MvcThrowCustomExceptionDashboardErrorToast/Views/Default/Index.vbhtml)) |
| 43 | + |
| 44 | +### Description |
| 45 | + |
| 46 | +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](https://docs.microsoft.com/en-us/dotnet/api/system.web.mvc.controller.onexception) method. |
| 47 | + |
| 48 | + |
| 49 | + |
| 50 | +- 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. |
| 51 | +- Specify the created custom controller's name in the view. |
| 52 | +- Use the created `CustomDashboard` controller when you map a dashboard route. |
| 53 | +- To throw an exception when the control loads a dashboard, create custom dashboard storage and override the `LoadDashboard` method. |
| 54 | + |
| 55 | +## Documentation |
| 56 | + |
| 57 | +- [Handle and Log Server-Side Errors in ASP.NET MVC](https://docs.devexpress.com/Dashboard/400025/web-dashboard/integrate-dashboard-component/aspnet-mvc-dashboard-extension/handle-and-log-server-side-errors-in-asp-net-mvc) |
| 58 | + |
| 59 | +## More Examples |
| 60 | + |
| 61 | +- [ASP.NET Web Forms Dashboard - How to handle errors](https://github.com/DevExpress-Examples/asp-net-web-forms-dashboard-change-default-error-text-callback-error) |
| 62 | +- [ASP.NET Core Dashboard - How to handle errors](https://github.com/DevExpress-Examples/asp-net-core-dashboard-change-default-error-text-exception-filter) |
| 63 | +<!-- feedback --> |
| 64 | +## Does this example address your development requirements/objectives? |
| 65 | + |
| 66 | +[<img src="https://www.devexpress.com/support/examples/i/yes-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=asp-net-mvc-dashboard-handle-errors&~~~was_helpful=yes) [<img src="https://www.devexpress.com/support/examples/i/no-button.svg"/>](https://www.devexpress.com/support/examples/survey.xml?utm_source=github&utm_campaign=asp-net-mvc-dashboard-handle-errors&~~~was_helpful=no) |
| 67 | + |
| 68 | +(you will be redirected to DevExpress.com to submit your response) |
| 69 | +<!-- feedback end --> |
0 commit comments