summaryrefslogtreecommitdiff
path: root/Blog/Components/Pages/Error.razor
diff options
context:
space:
mode:
Diffstat (limited to 'Blog/Components/Pages/Error.razor')
-rw-r--r--Blog/Components/Pages/Error.razor37
1 files changed, 37 insertions, 0 deletions
diff --git a/Blog/Components/Pages/Error.razor b/Blog/Components/Pages/Error.razor
new file mode 100644
index 0000000..6567978
--- /dev/null
+++ b/Blog/Components/Pages/Error.razor
@@ -0,0 +1,37 @@
1@page "/Error"
2@using System.Diagnostics
3@using Microsoft.AspNetCore.Http
4
5<PageTitle>Error</PageTitle>
6
7<h1 class="text-danger">Error.</h1>
8<h2 class="text-danger">An error occurred while processing your request.</h2>
9
10@if (ShowRequestId)
11{
12 <p>
13 <strong>Request ID:</strong> <code>@RequestId</code>
14 </p>
15}
16
17<h3>Development Mode</h3>
18<p>
19 Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
20</p>
21<p>
22 <strong>The Development environment shouldn't be enabled for deployed applications.</strong>
23 It can result in displaying sensitive information from exceptions to end users.
24 For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
25 and restarting the app.
26</p>
27
28@code{
29 [CascadingParameter] private HttpContext? HttpContext { get; set; }
30
31 private string? RequestId { get; set; }
32 private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
33
34 protected override void OnInitialized() =>
35 RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
36
37} \ No newline at end of file