1
0

Updated error page

Updated web.config
Updated README.md
This commit is contained in:
Michael Gordeev
2020-03-30 19:23:07 +03:00
parent e530fc2489
commit f87bac4266
6 changed files with 20 additions and 32 deletions
@@ -1,5 +1,4 @@
using System.Diagnostics;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using MyWebsite.Models.Databases;
using MyWebsite.ViewModels;
@@ -28,6 +27,10 @@ namespace MyWebsite.Controllers
[Route("Error")]
[ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
public IActionResult Error() =>
View(new ErrorViewModel(Database) { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
View();
[Route("GetError")]
public IActionResult GetError(int errorCode = 404) =>
StatusCode(errorCode);
}
}
+1
View File
@@ -54,6 +54,7 @@ namespace MyWebsite
app.UseHsts();
}
app.UseHttpsRedirection();
app.UseStatusCodePagesWithReExecute("/Error");
app.UseStaticFiles();
app.UseRouting();
@@ -1,12 +0,0 @@
using MyWebsite.Models.Databases;
namespace MyWebsite.ViewModels
{
public class ErrorViewModel : ViewModelBase
{
public ErrorViewModel(DatabaseContext context) : base(context) { }
public string RequestId { get; set; }
public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
}
}
+6 -10
View File
@@ -1,19 +1,15 @@
@model ErrorViewModel
@using Microsoft.AspNetCore.WebUtilities
@{
ViewData["Title"] = "Error";
}
<!-- TODO: Make Error page-->
<header>
<h1>Error</h1>
<h2>An error occurred while processing your request.</h2>
<h1>Error @Context.Response.StatusCode</h1>
<h2>@ReasonPhrases.GetReasonPhrase(Context.Response.StatusCode)</h2>
</header>
<article>
@if (Model.ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@Model.RequestId</code>
</p>
}
<p>
</p>
</article>
+5 -5
View File
@@ -7,25 +7,25 @@
<!--Legacy redirects-->
<rule name="GutSchedule API redirect" stopProcessing="true">
<match url="schedule_offset.txt" />
<action type="Redirect" url="https://xfox111.net/API/GUTSchedule/SemesterOffsetDay" redirectType="Permanent" appendQueryString="false" />
<action type="Redirect" url="/API/GUTSchedule/SemesterOffsetDay" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="GUT.Schedule Privacy policy" stopProcessing="true">
<match url="Projects/GUTSchedule/PrivacyPolicy.txt" />
<action type="Redirect" url="https://xfox111.net/Projects/GUTSchedule/PrivacyPolicy" redirectType="Permanent" appendQueryString="false" />
<action type="Redirect" url="/Projects/GUTSchedule/PrivacyPolicy" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="GUT.Schedule download page" stopProcessing="true">
<match url="guttime/get" />
<action type="Redirect" url="https://xfox111.net/Projects/GUTSchedule" redirectType="Permanent" appendQueryString="false" />
<action type="Redirect" url="/Projects/GUTSchedule" redirectType="Permanent" appendQueryString="false" />
</rule>
<rule name="FoxTubr Privacy policy" stopProcessing="true">
<match url="Projects/FoxTube/PrivacyPolicy.txt" />
<action type="Redirect" url="https://xfox111.net/Projects/FoxTube/PrivacyPolicy" redirectType="Permanent" appendQueryString="false" />
<action type="Redirect" url="/Projects/FoxTube/PrivacyPolicy" redirectType="Permanent" appendQueryString="false" />
</rule>
<!--/Legacy redirects-->
<!--Website maintainence redirect-->
<rule name="Construction redirect" stopProcessing="true" enabled="false">
<match url="^(?!Admin|API|Construction|css|assets|fonts|images)" />
<action type="Redirect" url="https://xfox111.net/Construction" redirectType="Temporary" appendQueryString="false" />
<action type="Rewrite" url="/Construction" appendQueryString="false" />
</rule>
<!--\Website maintainence redirect-->
</rules>