Error.razor 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. @page "/Error"
  2. @using System.Diagnostics
  3. <PageTitle>Error</PageTitle>
  4. <h1 class="text-danger">Error.</h1>
  5. <h2 class="text-danger">An error occurred while processing your request.</h2>
  6. @if (ShowRequestId)
  7. {
  8. <p>
  9. <strong>Request ID:</strong> <code>@RequestId</code>
  10. </p>
  11. }
  12. <h3>Development Mode</h3>
  13. <p>
  14. Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
  15. </p>
  16. <p>
  17. <strong>The Development environment shouldn't be enabled for deployed applications.</strong>
  18. It can result in displaying sensitive information from exceptions to end users.
  19. For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
  20. and restarting the app.
  21. </p>
  22. @code{
  23. [CascadingParameter] private HttpContext? HttpContext { get; set; }
  24. private string? RequestId { get; set; }
  25. private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
  26. protected override void OnInitialized() =>
  27. RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
  28. }