From cac51846e9a467445ccecec1c79f0717c742a899 Mon Sep 17 00:00:00 2001 From: Andrew Stanton-Nurse Date: Thu, 25 Jul 2019 13:01:00 -0700 Subject: [PATCH] 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 --- .../GenericHost/GenericWebHostedService.cs | 1 + src/Hosting/Hosting/src/Internal/WebHost.cs | 1 + src/Middleware/Diagnostics/Diagnostics.slnf | 45 ++ src/Servers/IIS/IIS/src/StartupHook.cs | 3 + src/Shared/ErrorPage/ErrorPage.Designer.cs | 651 +++++++++--------- src/Shared/ErrorPage/ErrorPageModel.cs | 2 + src/Shared/ErrorPage/GeneratePage.ps1 | 18 + src/Shared/ErrorPage/README.md | 14 + .../ErrorPage/{ => Views}/ErrorPage.cshtml | 31 +- .../ErrorPage/{ => Views}/ErrorPage.css | 0 src/Shared/ErrorPage/{ => Views}/ErrorPage.js | 0 11 files changed, 417 insertions(+), 349 deletions(-) create mode 100644 src/Middleware/Diagnostics/Diagnostics.slnf create mode 100644 src/Shared/ErrorPage/GeneratePage.ps1 create mode 100644 src/Shared/ErrorPage/README.md rename src/Shared/ErrorPage/{ => Views}/ErrorPage.cshtml (86%) rename src/Shared/ErrorPage/{ => Views}/ErrorPage.css (100%) rename src/Shared/ErrorPage/{ => Views}/ErrorPage.js (100%) diff --git a/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs b/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs index 5d7070fce8..89c6b4e941 100644 --- a/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs +++ b/src/Hosting/Hosting/src/GenericHost/GenericWebHostedService.cs @@ -167,6 +167,7 @@ namespace Microsoft.AspNetCore.Hosting .InformationalVersion; model.ClrVersion = clrVersion; model.OperatingSystemDescription = RuntimeInformation.OSDescription; + model.ShowRuntimeDetails = showDetailedErrors; if (showDetailedErrors) { diff --git a/src/Hosting/Hosting/src/Internal/WebHost.cs b/src/Hosting/Hosting/src/Internal/WebHost.cs index 504f1d2831..6e976959e7 100644 --- a/src/Hosting/Hosting/src/Internal/WebHost.cs +++ b/src/Hosting/Hosting/src/Internal/WebHost.cs @@ -264,6 +264,7 @@ namespace Microsoft.AspNetCore.Hosting .InformationalVersion; model.ClrVersion = clrVersion; model.OperatingSystemDescription = RuntimeInformation.OSDescription; + model.ShowRuntimeDetails = showDetailedErrors; if (showDetailedErrors) { diff --git a/src/Middleware/Diagnostics/Diagnostics.slnf b/src/Middleware/Diagnostics/Diagnostics.slnf new file mode 100644 index 0000000000..54b140b7bb --- /dev/null +++ b/src/Middleware/Diagnostics/Diagnostics.slnf @@ -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" + ] + } +} diff --git a/src/Servers/IIS/IIS/src/StartupHook.cs b/src/Servers/IIS/IIS/src/StartupHook.cs index 436a1cd079..5f8f3edf5a 100644 --- a/src/Servers/IIS/IIS/src/StartupHook.cs +++ b/src/Servers/IIS/IIS/src/StartupHook.cs @@ -83,7 +83,10 @@ internal class StartupHook new PhysicalFileProvider(contentRoot), 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.ShowRuntimeDetails = true; var errorPage = new ErrorPage(model); diff --git a/src/Shared/ErrorPage/ErrorPage.Designer.cs b/src/Shared/ErrorPage/ErrorPage.Designer.cs index 4cfcd48f6b..402e3ad494 100644 --- a/src/Shared/ErrorPage/ErrorPage.Designer.cs +++ b/src/Shared/ErrorPage/ErrorPage.Designer.cs @@ -1,87 +1,79 @@ +// +#pragma warning disable 1591 namespace Microsoft.AspNetCore.Hosting.Views { -#line 1 "ErrorPage.cshtml" -using System - -#line default -#line hidden - ; -#line 2 "ErrorPage.cshtml" -using System.Globalization - -#line default -#line hidden - ; -#line 3 "ErrorPage.cshtml" -using System.Linq - -#line default -#line hidden - ; -#line 4 "ErrorPage.cshtml" -using System.Net - -#line default -#line hidden - ; -#line 5 "ErrorPage.cshtml" -using System.Reflection - -#line default -#line hidden - ; -#line 6 "ErrorPage.cshtml" -using Microsoft.AspNetCore.Hosting.Views - -#line default -#line hidden - ; + #line hidden using System.Threading.Tasks; +#nullable restore +#line 1 "ErrorPage.cshtml" +using System; +#line default +#line hidden +#nullable disable +#nullable restore +#line 2 "ErrorPage.cshtml" +using System.Globalization; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 3 "ErrorPage.cshtml" +using System.Linq; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 4 "ErrorPage.cshtml" +using System.Net; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 5 "ErrorPage.cshtml" +using System.Reflection; + +#line default +#line hidden +#nullable disable +#nullable restore +#line 6 "ErrorPage.cshtml" +using Microsoft.AspNetCore.Hosting.Views; + +#line default +#line hidden +#nullable disable internal class ErrorPage : Microsoft.Extensions.RazorViews.BaseView { -#line 9 "ErrorPage.cshtml" - - public ErrorPage(ErrorPageModel model) - { - Model = model; - } - - public ErrorPageModel Model { get; set; } - -#line default -#line hidden - #line hidden - public ErrorPage() - { - } - #pragma warning disable 1998 - public override async Task ExecuteAsync() + public async override global::System.Threading.Tasks.Task ExecuteAsync() { WriteLiteral("\r\n"); +#nullable restore #line 17 "ErrorPage.cshtml" - + var location = string.Empty; #line default #line hidden - +#nullable disable WriteLiteral("\r\n