diff --git a/Components/Pages/Error.razor b/Components/Pages/Error.razor
new file mode 100644
index 0000000..b0d53cc
--- /dev/null
+++ b/Components/Pages/Error.razor
@@ -0,0 +1,27 @@
+@page "/error"
+@using System.Diagnostics
+
+@inject IHttpContextAccessor HttpContextAccessor
+
+Error
+
+
+ Unexpected Error
+
+ An error occurred while processing your request
+
+
+ @if (ShowRequestId) {
+
+ Request ID: @RequestId
+
+ }
+
+
+@code{
+ public string? RequestId { get; set; }
+ public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
+
+ protected override void OnInitialized() =>
+ RequestId = Activity.Current?.Id ?? HttpContextAccessor.HttpContext?.TraceIdentifier;
+}
diff --git a/Pages/Error.cshtml b/Pages/Error.cshtml
deleted file mode 100644
index 92dbc6e..0000000
--- a/Pages/Error.cshtml
+++ /dev/null
@@ -1,17 +0,0 @@
-@page
-@model ErrorModel
-@{
- ViewData["Title"] = "Error";
-}
-
-
-
Error.
-
An error occurred while processing your request.
-
- @if (Model.ShowRequestId)
- {
-
- Request ID: @Model.RequestId
-
- }
-
\ No newline at end of file
diff --git a/Pages/Error.cshtml.cs b/Pages/Error.cshtml.cs
deleted file mode 100644
index c8539be..0000000
--- a/Pages/Error.cshtml.cs
+++ /dev/null
@@ -1,27 +0,0 @@
-using Microsoft.AspNetCore.Mvc;
-using Microsoft.AspNetCore.Mvc.RazorPages;
-using System.Diagnostics;
-
-namespace JustShortIt.Pages
-{
- [ResponseCache(Duration = 0, Location = ResponseCacheLocation.None, NoStore = true)]
- [IgnoreAntiforgeryToken]
- public class ErrorModel : PageModel
- {
- public string? RequestId { get; set; }
-
- public bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
-
- private readonly ILogger _logger;
-
- public ErrorModel(ILogger logger)
- {
- _logger = logger;
- }
-
- public void OnGet()
- {
- RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
- }
- }
-}
\ No newline at end of file
diff --git a/Program.cs b/Program.cs
index 05c2afe..6ad045d 100644
--- a/Program.cs
+++ b/Program.cs
@@ -67,7 +67,7 @@
// Configure the HTTP request pipeline.
if (!app.Environment.IsDevelopment()) {
- app.UseExceptionHandler("/Error");
+ app.UseExceptionHandler("/error", createScopeForErrors: true);
}