Skip to content

Commit 229c250

Browse files
Merge pull request dotnet-architecture#221 from SychevIgor/ErrorInCatalogControllerFix
Error action extracted from CatalogController, because otherwise was …
2 parents 09dfd9a + c43d192 commit 229c250

3 files changed

Lines changed: 15 additions & 8 deletions

File tree

src/Web/WebMVC/Controllers/CatalogController.cs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,10 @@
11
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
42
using System.Threading.Tasks;
53
using Microsoft.AspNetCore.Mvc;
64
using Microsoft.eShopOnContainers.WebMVC.ViewModels.Pagination;
75
using Microsoft.eShopOnContainers.WebMVC.Services;
86
using Microsoft.eShopOnContainers.WebMVC.ViewModels.CatalogViewModels;
97

10-
118
namespace Microsoft.eShopOnContainers.WebMVC.Controllers
129
{
1310
public class CatalogController : Controller
@@ -42,8 +39,5 @@ public async Task<IActionResult> Index(int? BrandFilterApplied, int? TypesFilter
4239

4340
return View(vm);
4441
}
45-
46-
public IActionResult Error() => View();
4742
}
48-
}
49-
43+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
using Microsoft.AspNetCore.Mvc;
2+
3+
namespace WebMVC.Controllers
4+
{
5+
public class ErrorController : Controller
6+
{
7+
public IActionResult Error() => View();
8+
}
9+
}

src/Web/WebMVC/Startup.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
102102
}
103103
else
104104
{
105-
app.UseExceptionHandler("/Catalog/Error");
105+
app.UseExceptionHandler("/Error");
106106
}
107107

108108
app.UseSession();
@@ -145,6 +145,10 @@ public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerF
145145
routes.MapRoute(
146146
name: "default",
147147
template: "{controller=Catalog}/{action=Index}/{id?}");
148+
149+
routes.MapRoute(
150+
name: "defaultError",
151+
template: "{controller=Error}/{action=Error}");
148152
});
149153
}
150154
}

0 commit comments

Comments
 (0)