Update error page (#25706)
This commit is contained in:
parent
0637599517
commit
31fcc8bd26
|
|
@ -1,16 +1,42 @@
|
||||||
@page
|
@page
|
||||||
|
@model BlazorServerWeb_CSharp.Pages.ErrorModel
|
||||||
|
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html>
|
||||||
|
|
||||||
<h1 class="text-danger">Error.</h1>
|
<head>
|
||||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
<meta charset="utf-8" />
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
|
<title>Error</title>
|
||||||
|
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
|
||||||
|
<link href="~/css/app.css" rel="stylesheet" />
|
||||||
|
</head>
|
||||||
|
|
||||||
<h3>Development Mode</h3>
|
<body>
|
||||||
<p>
|
<div class="main">
|
||||||
Swapping to <strong>Development</strong> environment will display more detailed information about the error that occurred.
|
<div class="content px-4">
|
||||||
</p>
|
<h1 class="text-danger">Error.</h1>
|
||||||
<p>
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
|
||||||
It can result in displaying sensitive information from exceptions to end users.
|
@if (Model.ShowRequestId)
|
||||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
{
|
||||||
and restarting the app.
|
<p>
|
||||||
</p>
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,32 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Diagnostics;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using Microsoft.AspNetCore.Mvc.RazorPages;
|
||||||
|
using Microsoft.Extensions.Logging;
|
||||||
|
|
||||||
|
namespace BlazorServerWeb_CSharp.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<ErrorModel> _logger;
|
||||||
|
|
||||||
|
public ErrorModel(ILogger<ErrorModel> logger)
|
||||||
|
{
|
||||||
|
_logger = logger;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void OnGet()
|
||||||
|
{
|
||||||
|
RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -1,27 +1,42 @@
|
||||||
@page
|
@page
|
||||||
@model ComponentsWebAssembly_CSharp.Server.Pages.ErrorModel
|
@model ComponentsWebAssembly_CSharp.Server.Pages.ErrorModel
|
||||||
@{
|
|
||||||
Layout = "_Layout";
|
|
||||||
ViewData["Title"] = "Error";
|
|
||||||
}
|
|
||||||
|
|
||||||
<h1 class="text-danger">Error.</h1>
|
<!DOCTYPE html>
|
||||||
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
<html>
|
||||||
|
|
||||||
@if (Model.ShowRequestId)
|
<head>
|
||||||
{
|
<meta charset="utf-8" />
|
||||||
<p>
|
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no" />
|
||||||
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
<title>Error</title>
|
||||||
</p>
|
<link href="~/css/bootstrap/bootstrap.min.css" rel="stylesheet" />
|
||||||
}
|
<link href="~/css/app.css" rel="stylesheet" />
|
||||||
|
</head>
|
||||||
|
|
||||||
<h3>Development Mode</h3>
|
<body>
|
||||||
<p>
|
<div class="main">
|
||||||
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
|
<div class="content px-4">
|
||||||
</p>
|
<h1 class="text-danger">Error.</h1>
|
||||||
<p>
|
<h2 class="text-danger">An error occurred while processing your request.</h2>
|
||||||
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
|
||||||
It can result in displaying sensitive information from exceptions to end users.
|
@if (Model.ShowRequestId)
|
||||||
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
{
|
||||||
and restarting the app.
|
<p>
|
||||||
</p>
|
<strong>Request ID:</strong> <code>@Model.RequestId</code>
|
||||||
|
</p>
|
||||||
|
}
|
||||||
|
|
||||||
|
<h3>Development Mode</h3>
|
||||||
|
<p>
|
||||||
|
Swapping to the <strong>Development</strong> environment displays detailed information about the error that occurred.
|
||||||
|
</p>
|
||||||
|
<p>
|
||||||
|
<strong>The Development environment shouldn't be enabled for deployed applications.</strong>
|
||||||
|
It can result in displaying sensitive information from exceptions to end users.
|
||||||
|
For local debugging, enable the <strong>Development</strong> environment by setting the <strong>ASPNETCORE_ENVIRONMENT</strong> environment variable to <strong>Development</strong>
|
||||||
|
and restarting the app.
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</body>
|
||||||
|
|
||||||
|
</html>
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue