diff --git a/SharedLibraryCore/Services/ClientService.cs b/SharedLibraryCore/Services/ClientService.cs index f357ef2ad..795294dfa 100644 --- a/SharedLibraryCore/Services/ClientService.cs +++ b/SharedLibraryCore/Services/ClientService.cs @@ -299,6 +299,11 @@ namespace SharedLibraryCore.Services var client = await iqClient.FirstOrDefaultAsync(); + if (client == null) + { + return null; + } + var foundClient = new { Client = client, diff --git a/WebfrontCore/Controllers/HomeController.cs b/WebfrontCore/Controllers/HomeController.cs index c351122dc..b56cb2fdb 100644 --- a/WebfrontCore/Controllers/HomeController.cs +++ b/WebfrontCore/Controllers/HomeController.cs @@ -34,7 +34,12 @@ namespace WebfrontCore.Controllers ViewBag.Description = Localization["WEBFRONT_ERROR_DESC"]; ViewBag.Title = Localization["WEBFRONT_ERROR_TITLE"]; - return View(); + return View(exceptionFeature.Error); + } + + public IActionResult ResponseStatusCode(int? statusCode = null) + { + return View(statusCode); } } } diff --git a/WebfrontCore/Startup.cs b/WebfrontCore/Startup.cs index 61eeec9c4..304ed0c64 100644 --- a/WebfrontCore/Startup.cs +++ b/WebfrontCore/Startup.cs @@ -92,6 +92,8 @@ namespace WebfrontCore // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory) { + app.UseStatusCodePagesWithRedirects("/Home/ResponseStatusCode?statusCode={0}"); + if (env.EnvironmentName == "Development") { app.UseDeveloperExceptionPage(); diff --git a/WebfrontCore/Views/Shared/Error.cshtml b/WebfrontCore/Views/Shared/Error.cshtml index 6fac1a571..95c2db318 100644 --- a/WebfrontCore/Views/Shared/Error.cshtml +++ b/WebfrontCore/Views/Shared/Error.cshtml @@ -1,6 +1,15 @@ -@{ +@model Exception +@using SharedLibraryCore + +@{ ViewData["Title"] = "Error"; }

@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_TITLE"]

@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_DESC"]

+ + @if (Model != null) + { + @SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_CODE"].FormatExt(Model.Message); + } + diff --git a/WebfrontCore/Views/Shared/ResponseStatusCode.cshtml b/WebfrontCore/Views/Shared/ResponseStatusCode.cshtml new file mode 100644 index 000000000..384a43601 --- /dev/null +++ b/WebfrontCore/Views/Shared/ResponseStatusCode.cshtml @@ -0,0 +1,13 @@ +@model int +@{ + ViewData["Title"] = "Error"; +} + +

@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_TITLE"]

+

@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_DESC"]

+ + @if (Model == 404) + { + @SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_NOTFOUND"] + } + \ No newline at end of file