Skip to content

Commit 305445f

Browse files
auto sync for version 2023.1
1 parent eb5f94c commit 305445f

17 files changed

+360
-366
lines changed
Lines changed: 20 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,20 @@
1-
<Project Sdk="Microsoft.NET.Sdk.Web">
2-
<PropertyGroup>
3-
<TargetFramework>net6.0</TargetFramework>
4-
<RootNamespace>AspNetCoreCustomExceptionErrorToast</RootNamespace>
5-
</PropertyGroup>
6-
<ItemGroup>
7-
<PackageReference Include="BuildBundlerMinifier" Version="3.2.435" />
8-
<PackageReference Include="DevExpress.AspNetCore.Dashboard" Version="22.2.2" />
9-
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="3.1.9" />
10-
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="3.1.9">
11-
<PrivateAssets>all</PrivateAssets>
12-
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13-
</PackageReference>
14-
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
15-
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.0" />
16-
</ItemGroup>
17-
<ItemGroup>
18-
<Folder Include="App_Data\Dashboards\" />
19-
</ItemGroup>
20-
</Project>
21-
1+
<Project Sdk="Microsoft.NET.Sdk.Web">
2+
<PropertyGroup>
3+
<TargetFramework>net6.0</TargetFramework>
4+
<RootNamespace>AspNetCoreCustomExceptionErrorToast</RootNamespace>
5+
</PropertyGroup>
6+
<ItemGroup>
7+
<PackageReference Include="BuildBundlerMinifier" Version="3.2.435" />
8+
<PackageReference Include="DevExpress.AspNetCore.Dashboard" Version="23.1.*-*" />
9+
<PackageReference Include="Microsoft.EntityFrameworkCore.SqlServer" Version="6.0.18" />
10+
<PackageReference Include="Microsoft.EntityFrameworkCore.Tools" Version="6.0.18">
11+
<PrivateAssets>all</PrivateAssets>
12+
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
13+
</PackageReference>
14+
<PackageReference Include="Microsoft.Extensions.Logging.Debug" Version="6.0.0" />
15+
<PackageReference Include="Microsoft.VisualStudio.Web.CodeGeneration.Design" Version="6.0.14" />
16+
</ItemGroup>
17+
<ItemGroup>
18+
<Folder Include="App_Data\Dashboards\" />
19+
</ItemGroup>
20+
</Project>
Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
using DevExpress.DashboardAspNetCore;
2-
using DevExpress.DashboardWeb;
3-
using Microsoft.AspNetCore.Mvc;
4-
5-
namespace AspNetCoreThrowCustomExceptionDashboardErrorToast.Controllers {
6-
[TypeFilter(typeof(CustomExceptionFilter))]
7-
public class CustomDashboardController : DashboardController {
8-
public CustomDashboardController(DashboardConfigurator configurator) : base(configurator) { }
9-
}
10-
}
1+
using DevExpress.DashboardAspNetCore;
2+
using DevExpress.DashboardWeb;
3+
using Microsoft.AspNetCore.Mvc;
4+
5+
namespace AspNetCoreThrowCustomExceptionDashboardErrorToast.Controllers {
6+
[TypeFilter(typeof(CustomExceptionFilter))]
7+
public class CustomDashboardController : DashboardController {
8+
public CustomDashboardController(DashboardConfigurator configurator) : base(configurator) { }
9+
}
10+
}
Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,15 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Mvc;
6-
7-
namespace AspNetCoreThrowCustomExceptionDashboardErrorToast.Controllers
8-
{
9-
public class HomeController : Controller
10-
{
11-
public IActionResult Index() {
12-
return View();
13-
}
14-
}
15-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Mvc;
6+
7+
namespace AspNetCoreThrowCustomExceptionDashboardErrorToast.Controllers
8+
{
9+
public class HomeController : Controller
10+
{
11+
public IActionResult Index() {
12+
return View();
13+
}
14+
}
15+
}
Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,22 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Threading.Tasks;
5-
using Microsoft.AspNetCore.Hosting;
6-
using Microsoft.Extensions.Configuration;
7-
using Microsoft.Extensions.Hosting;
8-
using Microsoft.Extensions.Logging;
9-
10-
namespace AspNetCoreThrowCustomExceptionDashboardErrorToast {
11-
public class Program {
12-
public static void Main(string[] args) {
13-
CreateHostBuilder(args).Build().Run();
14-
}
15-
16-
public static IHostBuilder CreateHostBuilder(string[] args) =>
17-
Host.CreateDefaultBuilder(args)
18-
.ConfigureWebHostDefaults(webBuilder => {
19-
webBuilder.UseStartup<Startup>();
20-
});
21-
}
22-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Threading.Tasks;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.Extensions.Configuration;
7+
using Microsoft.Extensions.Hosting;
8+
using Microsoft.Extensions.Logging;
9+
10+
namespace AspNetCoreThrowCustomExceptionDashboardErrorToast {
11+
public class Program {
12+
public static void Main(string[] args) {
13+
CreateHostBuilder(args).Build().Run();
14+
}
15+
16+
public static IHostBuilder CreateHostBuilder(string[] args) =>
17+
Host.CreateDefaultBuilder(args)
18+
.ConfigureWebHostDefaults(webBuilder => {
19+
webBuilder.UseStartup<Startup>();
20+
});
21+
}
22+
}
Lines changed: 97 additions & 97 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,97 @@
1-
using DevExpress.AspNetCore;
2-
using DevExpress.DashboardAspNetCore;
3-
using DevExpress.DashboardWeb;
4-
using Microsoft.AspNetCore.Builder;
5-
using Microsoft.AspNetCore.Hosting;
6-
using Microsoft.AspNetCore.Mvc;
7-
using Microsoft.AspNetCore.Mvc.Filters;
8-
using Microsoft.Extensions.Configuration;
9-
using Microsoft.Extensions.DependencyInjection;
10-
using Microsoft.Extensions.Hosting;
11-
using System;
12-
using System.Collections.Generic;
13-
using System.Net;
14-
using System.Xml.Linq;
15-
16-
namespace AspNetCoreThrowCustomExceptionDashboardErrorToast {
17-
public class Startup {
18-
public Startup(IConfiguration configuration, IWebHostEnvironment env) {
19-
}
20-
21-
public void ConfigureServices(IServiceCollection services) {
22-
services.AddMvc();
23-
services.AddDevExpressControls();
24-
services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
25-
DashboardConfigurator configurator = new DashboardConfigurator();
26-
configurator.SetDashboardStorage(new CustomDashboardStorage());
27-
return configurator;
28-
});
29-
}
30-
31-
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
32-
if(env.IsDevelopment()) {
33-
app.UseDeveloperExceptionPage();
34-
}
35-
36-
app.UseRouting();
37-
38-
app.UseEndpoints(endpoints => {
39-
endpoints.MapDashboardRoute("api/dashboards", "CustomDashboard");
40-
endpoints.MapControllerRoute(
41-
name: "default",
42-
pattern: "{controller=Home}/{action=Index}/{id?}"
43-
);
44-
});
45-
46-
app.UseStaticFiles();
47-
app.UseDevExpressControls();
48-
}
49-
}
50-
51-
public class CustomException : Exception {
52-
public const string SafeMessage = "Custom exception text for end users";
53-
public const string UnsafeMessage = "Custom exception text for developers";
54-
}
55-
56-
public class CustomDashboardStorage : IDashboardStorage {
57-
IEnumerable<DashboardInfo> IDashboardStorage.GetAvailableDashboardsInfo() {
58-
return new[] {
59-
new DashboardInfo { ID = "Dashboard", Name = "Dashboard" }
60-
};
61-
}
62-
XDocument IDashboardStorage.LoadDashboard(string dashboardID) {
63-
// Custom Exception:
64-
throw new CustomException();
65-
}
66-
void IDashboardStorage.SaveDashboard(string dashboardID, XDocument dashboard) {
67-
}
68-
}
69-
70-
public class CustomExceptionFilter : IExceptionFilter {
71-
internal bool isDevelopmentMode = false;
72-
73-
public CustomExceptionFilter(IWebHostEnvironment hostingEnvironment) {
74-
this.isDevelopmentMode = hostingEnvironment.IsDevelopment();
75-
}
76-
string GetJson(string message) {
77-
return $"{{ \"Message\":\"{message}\" }}";
78-
}
79-
80-
public virtual void OnException(ExceptionContext context) {
81-
if(context.ExceptionHandled || context.Exception == null) {
82-
return;
83-
}
84-
85-
CustomException customException = context.Exception as CustomException;
86-
string message = customException != null ? (isDevelopmentMode ? CustomException.UnsafeMessage : CustomException.SafeMessage) : "";
87-
88-
context.Result = new ContentResult {
89-
Content = GetJson(message),
90-
ContentType = "application/json",
91-
StatusCode = (int)HttpStatusCode.BadRequest
92-
};
93-
94-
context.ExceptionHandled = true;
95-
}
96-
}
97-
}
1+
using DevExpress.AspNetCore;
2+
using DevExpress.DashboardAspNetCore;
3+
using DevExpress.DashboardWeb;
4+
using Microsoft.AspNetCore.Builder;
5+
using Microsoft.AspNetCore.Hosting;
6+
using Microsoft.AspNetCore.Mvc;
7+
using Microsoft.AspNetCore.Mvc.Filters;
8+
using Microsoft.Extensions.Configuration;
9+
using Microsoft.Extensions.DependencyInjection;
10+
using Microsoft.Extensions.Hosting;
11+
using System;
12+
using System.Collections.Generic;
13+
using System.Net;
14+
using System.Xml.Linq;
15+
16+
namespace AspNetCoreThrowCustomExceptionDashboardErrorToast {
17+
public class Startup {
18+
public Startup(IConfiguration configuration, IWebHostEnvironment env) {
19+
}
20+
21+
public void ConfigureServices(IServiceCollection services) {
22+
services.AddMvc();
23+
services.AddDevExpressControls();
24+
services.AddScoped<DashboardConfigurator>((IServiceProvider serviceProvider) => {
25+
DashboardConfigurator configurator = new DashboardConfigurator();
26+
configurator.SetDashboardStorage(new CustomDashboardStorage());
27+
return configurator;
28+
});
29+
}
30+
31+
public void Configure(IApplicationBuilder app, IWebHostEnvironment env) {
32+
if(env.IsDevelopment()) {
33+
app.UseDeveloperExceptionPage();
34+
}
35+
36+
app.UseRouting();
37+
38+
app.UseEndpoints(endpoints => {
39+
endpoints.MapDashboardRoute("api/dashboards", "CustomDashboard");
40+
endpoints.MapControllerRoute(
41+
name: "default",
42+
pattern: "{controller=Home}/{action=Index}/{id?}"
43+
);
44+
});
45+
46+
app.UseStaticFiles();
47+
app.UseDevExpressControls();
48+
}
49+
}
50+
51+
public class CustomException : Exception {
52+
public const string SafeMessage = "Custom exception text for end users";
53+
public const string UnsafeMessage = "Custom exception text for developers";
54+
}
55+
56+
public class CustomDashboardStorage : IDashboardStorage {
57+
IEnumerable<DashboardInfo> IDashboardStorage.GetAvailableDashboardsInfo() {
58+
return new[] {
59+
new DashboardInfo { ID = "Dashboard", Name = "Dashboard" }
60+
};
61+
}
62+
XDocument IDashboardStorage.LoadDashboard(string dashboardID) {
63+
// Custom Exception:
64+
throw new CustomException();
65+
}
66+
void IDashboardStorage.SaveDashboard(string dashboardID, XDocument dashboard) {
67+
}
68+
}
69+
70+
public class CustomExceptionFilter : IExceptionFilter {
71+
internal bool isDevelopmentMode = false;
72+
73+
public CustomExceptionFilter(IWebHostEnvironment hostingEnvironment) {
74+
this.isDevelopmentMode = hostingEnvironment.IsDevelopment();
75+
}
76+
string GetJson(string message) {
77+
return $"{{ \"Message\":\"{message}\" }}";
78+
}
79+
80+
public virtual void OnException(ExceptionContext context) {
81+
if(context.ExceptionHandled || context.Exception == null) {
82+
return;
83+
}
84+
85+
CustomException customException = context.Exception as CustomException;
86+
string message = customException != null ? (isDevelopmentMode ? CustomException.UnsafeMessage : CustomException.SafeMessage) : "";
87+
88+
context.Result = new ContentResult {
89+
Content = GetJson(message),
90+
ContentType = "application/json",
91+
StatusCode = (int)HttpStatusCode.BadRequest
92+
};
93+
94+
context.ExceptionHandled = true;
95+
}
96+
}
97+
}

CS/AspNetCoreCustomExceptionErrorToast/bundleconfig.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
{
33
"outputFileName": "wwwroot/css/site.min.css",
44
"inputFiles": [
5-
"node_modules/devextreme/dist/css/dx.common.css",
6-
"node_modules/devextreme/dist/css/dx.light.css",
5+
"node_modules/devextreme-dist/css/dx.common.css",
6+
"node_modules/devextreme-dist/css/dx.light.css",
77
"node_modules/@devexpress/analytics-core/dist/css/dx-analytics.common.css",
88
"node_modules/@devexpress/analytics-core/dist/css/dx-analytics.light.css",
99
"node_modules/@devexpress/analytics-core/dist/css/dx-querybuilder.css",
@@ -18,13 +18,12 @@
1818
"outputFileName": "wwwroot/js/site.min.js",
1919
"inputFiles": [
2020
"node_modules/jquery/dist/jquery.js",
21-
"node_modules/jquery-ui-dist/jquery-ui.js",
2221
"node_modules/knockout/build/output/knockout-latest.js",
2322
"node_modules/ace-builds/src-min-noconflict/ace.js",
2423
"node_modules/ace-builds/src-min-noconflict/ext-language_tools.js",
2524
"node_modules/ace-builds/src-min-noconflict/theme-dreamweaver.js",
2625
"node_modules/ace-builds/src-min-noconflict/theme-ambiance.js",
27-
"node_modules/devextreme/dist/js/dx.all.js",
26+
"node_modules/devextreme-dist/js/dx.all.js",
2827
"node_modules/@devexpress/analytics-core/dist/js/dx-analytics-core.min.js",
2928
"node_modules/@devexpress/analytics-core/dist/js/dx-querybuilder.min.js",
3029
"node_modules/devexpress-dashboard/dist/js/dx-dashboard.min.js"
Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
1-
{
2-
"version": "1.0.0",
3-
"name": "asp.net",
4-
"private": true,
5-
"license": "MIT",
6-
"devDependencies": {
7-
"devextreme": "22.2-stable",
8-
"@devexpress/analytics-core": "22.2-stable",
9-
"devexpress-dashboard": "22.2-stable",
10-
"jquery-ui-dist": "^1.12.1"
11-
}
12-
}
1+
{
2+
"version": "1.0.0",
3+
"name": "asp.net",
4+
"private": true,
5+
"license": "MIT",
6+
"devDependencies": {
7+
"devextreme-dist": "23.1-next",
8+
"@devexpress/analytics-core": "23.1-next",
9+
"devexpress-dashboard": "23.1-next"
10+
}
11+
}

0 commit comments

Comments
 (0)