diff --git a/BTCPayServer/Controllers/ErrorController.cs b/BTCPayServer/Controllers/ErrorController.cs new file mode 100644 index 000000000..29a02b9e7 --- /dev/null +++ b/BTCPayServer/Controllers/ErrorController.cs @@ -0,0 +1,18 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Microsoft.AspNetCore.Mvc; + +namespace BTCPayServer.Controllers +{ + [Route("[controller]/[action]")] + public class ErrorController : Controller + { + public IActionResult Handle(int? statusCode = null) + { + return View(statusCode); + } + } +} diff --git a/BTCPayServer/Hosting/Startup.cs b/BTCPayServer/Hosting/Startup.cs index 541f5cb3f..a88e7f037 100644 --- a/BTCPayServer/Hosting/Startup.cs +++ b/BTCPayServer/Hosting/Startup.cs @@ -241,6 +241,10 @@ namespace BTCPayServer.Hosting forwardingOptions.KnownProxies.Clear(); forwardingOptions.ForwardedHeaders = ForwardedHeaders.All; app.UseForwardedHeaders(forwardingOptions); + + + app.UseStatusCodePagesWithReExecute("/Error/Handle", "?statusCode={0}"); + app.UsePayServer(); app.UseRouting(); app.UseCors(); @@ -252,7 +256,6 @@ namespace BTCPayServer.Hosting app.UseSession(); app.UseWebSockets(); - app.UseStatusCodePages(); app.UseEndpoints(endpoints => { diff --git a/BTCPayServer/Views/Error/Handle.cshtml b/BTCPayServer/Views/Error/Handle.cshtml new file mode 100644 index 000000000..f14d7711a --- /dev/null +++ b/BTCPayServer/Views/Error/Handle.cshtml @@ -0,0 +1,19 @@ +@using System.Net +@model int? +@{ + ViewData["ErrorTitle"] = "Generic Error occurred"; + if (Model.HasValue) + { + var httpCode = (HttpStatusCode)Model.Value; + ViewData["ErrorTitle"] = $"{(int)httpCode} - {httpCode.ToString()}"; + } +} + +
+ Generic error occurred, HTTP Code: @Model
+
+ Consult server log for more details.
+
+ Navigate back to home.
+
+
BTCPay Server is a self-hosted, open-source cryptocurrency payment processor. It is secure, private, censorship-resistant and free.
-