Learn.VideoAnalysis/VideoAnalysis/Components/Error.razor

37 lines
1.1 KiB
Plaintext

@page "/Error"
@using System.Diagnostics
<PageTitle>Error</PageTitle>
<h1 class="text-danger">错误页面.</h1>
<h2 class="text-danger">处理您的请求时出错。</h2>
@if (ShowRequestId)
{
<p>
<strong>Request ID:</strong> <code>@RequestId</code>
</p>
}
<h3>开发模式</h3>
<p>
切换到<strong>Development</strong>环境将显示有关发生的错误的更多详细信息。
</p>
<p>
<strong> 不应为已部署的应用程序启用开发环境。</strong>
它可能导致向最终用户显示来自异常的敏感信息。
对于本地调试,通过将 <strong>ASPNETCORE_ENVIRONMENT</strong> 环境变量设置为 <strong>Development</strong> 来启用 <strong> 开发 </strong> 环境
并重新启动应用程序。
</p>
@code{
[CascadingParameter]
private HttpContext? HttpContext { get; set; }
private string? RequestId { get; set; }
private bool ShowRequestId => !string.IsNullOrEmpty(RequestId);
protected override void OnInitialized() =>
RequestId = Activity.Current?.Id ?? HttpContext?.TraceIdentifier;
}