add more informative 404 errors

This commit is contained in:
RaidMax 2019-10-23 13:35:20 -05:00
parent f31ce6b001
commit cb9119ac58
5 changed files with 36 additions and 2 deletions

View File

@ -299,6 +299,11 @@ namespace SharedLibraryCore.Services
var client = await iqClient.FirstOrDefaultAsync(); var client = await iqClient.FirstOrDefaultAsync();
if (client == null)
{
return null;
}
var foundClient = new var foundClient = new
{ {
Client = client, Client = client,

View File

@ -34,7 +34,12 @@ namespace WebfrontCore.Controllers
ViewBag.Description = Localization["WEBFRONT_ERROR_DESC"]; ViewBag.Description = Localization["WEBFRONT_ERROR_DESC"];
ViewBag.Title = Localization["WEBFRONT_ERROR_TITLE"]; ViewBag.Title = Localization["WEBFRONT_ERROR_TITLE"];
return View(); return View(exceptionFeature.Error);
}
public IActionResult ResponseStatusCode(int? statusCode = null)
{
return View(statusCode);
} }
} }
} }

View File

@ -92,6 +92,8 @@ namespace WebfrontCore
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. // 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) public void Configure(IApplicationBuilder app, IWebHostEnvironment env, ILoggerFactory loggerFactory)
{ {
app.UseStatusCodePagesWithRedirects("/Home/ResponseStatusCode?statusCode={0}");
if (env.EnvironmentName == "Development") if (env.EnvironmentName == "Development")
{ {
app.UseDeveloperExceptionPage(); app.UseDeveloperExceptionPage();

View File

@ -1,6 +1,15 @@
@{ @model Exception
@using SharedLibraryCore
@{
ViewData["Title"] = "Error"; ViewData["Title"] = "Error";
} }
<h4 class="text-danger">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_TITLE"]</h4> <h4 class="text-danger">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_TITLE"]</h4>
<h4 class="text-danger">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_DESC"]</h4> <h4 class="text-danger">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_DESC"]</h4>
<strong class="text-warning">
@if (Model != null)
{
@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_CODE"].FormatExt(Model.Message);
}
</strong>

View File

@ -0,0 +1,13 @@
@model int
@{
ViewData["Title"] = "Error";
}
<h4 class="text-danger">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_TITLE"]</h4>
<h4 class="text-danger">@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_GENERIC_DESC"]</h4>
<strong class="text-warning">
@if (Model == 404)
{
@SharedLibraryCore.Utilities.CurrentLocalization.LocalizationIndex["WEBFRONT_ERROR_NOTFOUND"]
}
</strong>