| 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 |
} |