fix #12516 by cleaning up Hosting error page (#12545)

* fix #12516 by cleaning up error page

* add a Diagnostics.slnf because I was there

* missed the IIS update

* update WebHost's error page

* Fix slnf path
This commit is contained in:
Andrew Stanton-Nurse 2019-07-25 13:01:00 -07:00 committed by GitHub
parent e0d522e1f7
commit cac51846e9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 417 additions and 349 deletions

View File

@ -167,6 +167,7 @@ namespace Microsoft.AspNetCore.Hosting
.InformationalVersion; .InformationalVersion;
model.ClrVersion = clrVersion; model.ClrVersion = clrVersion;
model.OperatingSystemDescription = RuntimeInformation.OSDescription; model.OperatingSystemDescription = RuntimeInformation.OSDescription;
model.ShowRuntimeDetails = showDetailedErrors;
if (showDetailedErrors) if (showDetailedErrors)
{ {

View File

@ -264,6 +264,7 @@ namespace Microsoft.AspNetCore.Hosting
.InformationalVersion; .InformationalVersion;
model.ClrVersion = clrVersion; model.ClrVersion = clrVersion;
model.OperatingSystemDescription = RuntimeInformation.OSDescription; model.OperatingSystemDescription = RuntimeInformation.OSDescription;
model.ShowRuntimeDetails = showDetailedErrors;
if (showDetailedErrors) if (showDetailedErrors)
{ {

View File

@ -0,0 +1,45 @@
{
"solution": {
"path": "..\\Middleware.sln",
"projects": [
"..\\Hosting\\Abstractions\\src\\Microsoft.AspNetCore.Hosting.Abstractions.csproj",
"..\\Hosting\\Hosting\\src\\Microsoft.AspNetCore.Hosting.csproj",
"..\\Hosting\\Server.Abstractions\\src\\Microsoft.AspNetCore.Hosting.Server.Abstractions.csproj",
"..\\Hosting\\TestHost\\src\\Microsoft.AspNetCore.TestHost.csproj",
"..\\Http\\Authentication.Abstractions\\src\\Microsoft.AspNetCore.Authentication.Abstractions.csproj",
"..\\Http\\Authentication.Core\\src\\Microsoft.AspNetCore.Authentication.Core.csproj",
"..\\Http\\Http.Abstractions\\src\\Microsoft.AspNetCore.Http.Abstractions.csproj",
"..\\Http\\Http.Extensions\\src\\Microsoft.AspNetCore.Http.Extensions.csproj",
"..\\Http\\Http.Features\\src\\Microsoft.AspNetCore.Http.Features.csproj",
"..\\Http\\Metadata\\src\\Microsoft.AspNetCore.Metadata.csproj",
"..\\Http\\Routing.Abstractions\\src\\Microsoft.AspNetCore.Routing.Abstractions.csproj",
"..\\Http\\WebUtilities\\src\\Microsoft.AspNetCore.WebUtilities.csproj",
"..\\Security\\Authorization\\Core\\src\\Microsoft.AspNetCore.Authorization.csproj",
"..\\Servers\\Connections.Abstractions\\src\\Microsoft.AspNetCore.Connections.Abstractions.csproj",
"..\\Servers\\IIS\\IISIntegration\\src\\Microsoft.AspNetCore.Server.IISIntegration.csproj",
"..\\Servers\\Kestrel\\Core\\src\\Microsoft.AspNetCore.Server.Kestrel.Core.csproj",
"..\\Servers\\Kestrel\\Kestrel\\src\\Microsoft.AspNetCore.Server.Kestrel.csproj",
"..\\Servers\\Kestrel\\Transport.Sockets\\src\\Microsoft.AspNetCore.Server.Kestrel.Transport.Sockets.csproj",
"..\\http\\Headers\\src\\Microsoft.Net.Http.Headers.csproj",
"..\\http\\Routing\\src\\Microsoft.AspNetCore.Routing.csproj",
"..\\http\\http\\src\\Microsoft.AspNetCore.Http.csproj",
"Diagnostics.Abstractions\\src\\Microsoft.AspNetCore.Diagnostics.Abstractions.csproj",
"Diagnostics.EntityFrameworkCore\\src\\Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.csproj",
"Diagnostics.EntityFrameworkCore\\test\\FunctionalTests\\Diagnostics.EFCore.FunctionalTests.csproj",
"Diagnostics.EntityFrameworkCore\\test\\UnitTests\\Microsoft.AspNetCore.Diagnostics.EntityFrameworkCore.Tests.csproj",
"Diagnostics\\src\\Microsoft.AspNetCore.Diagnostics.csproj",
"Diagnostics\\test\\FunctionalTests\\Diagnostics.FunctionalTests.csproj",
"Diagnostics\\test\\UnitTests\\Microsoft.AspNetCore.Diagnostics.Tests.csproj",
"Diagnostics\\test\\testassets\\ClassLibraryWithPortablePdbs\\ClassLibraryWithPortablePdbs.csproj",
"Diagnostics\\test\\testassets\\DatabaseErrorPageSample\\DatabaseErrorPageSample.csproj",
"Diagnostics\\test\\testassets\\DeveloperExceptionPageSample\\DeveloperExceptionPageSample.csproj",
"Diagnostics\\test\\testassets\\ExceptionHandlerSample\\ExceptionHandlerSample.csproj",
"Diagnostics\\test\\testassets\\StatusCodePagesSample\\StatusCodePagesSample.csproj",
"Diagnostics\\test\\testassets\\WelcomePageSample\\WelcomePageSample.csproj",
"HttpOverrides\\src\\Microsoft.AspNetCore.HttpOverrides.csproj",
"MiddlewareAnalysis\\samples\\MiddlewareAnalysisSample\\MiddlewareAnalysisSample.csproj",
"MiddlewareAnalysis\\src\\Microsoft.AspNetCore.MiddlewareAnalysis.csproj",
"StaticFiles\\src\\Microsoft.AspNetCore.StaticFiles.csproj"
]
}
}

View File

@ -83,7 +83,10 @@ internal class StartupHook
new PhysicalFileProvider(contentRoot), new PhysicalFileProvider(contentRoot),
sourceCodeLineCount: 6); sourceCodeLineCount: 6);
// The startup hook is only present when detailed errors are allowed, so
// we can turn on all the details.
model.ErrorDetails = exceptionDetailProvider.GetDetails(exception); model.ErrorDetails = exceptionDetailProvider.GetDetails(exception);
model.ShowRuntimeDetails = true;
var errorPage = new ErrorPage(model); var errorPage = new ErrorPage(model);

File diff suppressed because it is too large Load Diff

View File

@ -16,6 +16,8 @@ namespace Microsoft.AspNetCore.Hosting.Views
/// </summary> /// </summary>
public IEnumerable<ExceptionDetails> ErrorDetails { get; set; } public IEnumerable<ExceptionDetails> ErrorDetails { get; set; }
public bool ShowRuntimeDetails { get; set; }
public string RuntimeDisplayName { get; set; } public string RuntimeDisplayName { get; set; }
public string RuntimeArchitecture { get; set; } public string RuntimeArchitecture { get; set; }

View File

@ -0,0 +1,18 @@
param(
[Parameter(Mandatory = $true)][string]$ToolingRepoPath
)
$ToolPath = Join-Path $ToolingRepoPath "artifacts\bin\RazorPageGenerator\Debug\netcoreapp3.0\dotnet-razorpagegenerator.exe"
if (!(Test-Path $ToolPath)) {
throw "Unable to find razor page generator tool at $ToolPath"
}
& "$ToolPath" Microsoft.AspNetCore.Hosting.Views $PSScriptRoot
$TargetPath = Join-Path $PSScriptRoot "ErrorPage.Designer.cs"
if (Test-Path $TargetPath) {
Remove-Item $TargetPath
}
Move-Item "$PSScriptRoot\Views\ErrorPage.Designer.cs" $PSScriptRoot

View File

@ -0,0 +1,14 @@
# Error Page
This folder is shared among multiple projects. The `ErrorPage.Designer.cs` and `ErrorPageModel.cs` files are used to render this view. The `ErrorPage.Designer.cs` file is generated by rendering `src/Views/ErrorPage.cshtml` using the [RazorPageGenerator](https://github.com/aspnet/AspNetCore-Tooling/tree/master/src/Razor/src/RazorPageGenerator) tool.
## Making changes to ErrorPage.cshtml
1. Clone aspnet/AspNetCore-Tooling
1. Run `./build.cmd` in **that repo**
1. Edit the file
1. Run the `GeneratePage` script, passing in the path to the `aspnet/AspNetCore-Tooling` repo root.
```
.\GeneratePage -ToolingRepoPath C:\Code\aspnet\AspNetCore-Tooling
```

View File

@ -31,12 +31,11 @@
@foreach (var errorDetail in Model.ErrorDetails) @foreach (var errorDetail in Model.ErrorDetails)
{ {
<div class="titleerror">@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }</div> <div class="titleerror">@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }</div>
@{
var firstFrame = errorDetail.StackFrames.FirstOrDefault(); var firstFrame = errorDetail.StackFrames.FirstOrDefault();
if (firstFrame != null) if (firstFrame != null)
{ {
location = firstFrame.Function; location = firstFrame.Function;
}
} }
if (!string.IsNullOrEmpty(location) && firstFrame != null && !string.IsNullOrEmpty(firstFrame.File)) if (!string.IsNullOrEmpty(location) && firstFrame != null && !string.IsNullOrEmpty(firstFrame.File))
{ {
@ -76,19 +75,15 @@
} }
@foreach (var errorDetail in Model.ErrorDetails) @foreach (var errorDetail in Model.ErrorDetails)
{ {
@{ exceptionCount++;
exceptionCount++; exceptionDetailId = "exceptionDetail" + exceptionCount;
exceptionDetailId = "exceptionDetail" + exceptionCount;
}
<li> <li>
<h2 class="stackerror">@errorDetail.Error.GetType().Name: @errorDetail.Error.Message</h2> <h2 class="stackerror">@errorDetail.Error.GetType().Name: @errorDetail.Error.Message</h2>
<ul> <ul>
@foreach (var frame in errorDetail.StackFrames) @foreach (var frame in errorDetail.StackFrames)
{ {
@{ stackFrameCount++;
stackFrameCount++; frameId = "frame" + stackFrameCount;
frameId = "frame" + stackFrameCount;
}
<li class="frame" id="@frameId"> <li class="frame" id="@frameId">
@if (string.IsNullOrEmpty(frame.File)) @if (string.IsNullOrEmpty(frame.File))
{ {
@ -149,9 +144,11 @@
} }
</ul> </ul>
</div> </div>
<footer> @if (Model.ShowRuntimeDetails) {
@Model.RuntimeDisplayName @Model.RuntimeArchitecture v@(Model.ClrVersion) &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Microsoft.AspNetCore.Hosting version @Model.CurrentAssemblyVesion &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; @Model.OperatingSystemDescription &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="http://go.microsoft.com/fwlink/?LinkId=517394">Need help?</a> <footer>
</footer> @Model.RuntimeDisplayName @Model.RuntimeArchitecture v@(Model.ClrVersion) &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;Microsoft.AspNetCore.Hosting version @Model.CurrentAssemblyVesion &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp; @Model.OperatingSystemDescription &nbsp;&nbsp;&nbsp;|&nbsp;&nbsp;&nbsp;<a href="http://go.microsoft.com/fwlink/?LinkId=517394">Need help?</a>
</footer>
}
<script> <script>
//<!-- //<!--
<%$ include: ErrorPage.js %> <%$ include: ErrorPage.js %>