Skip to content

Conversation

@analogrelay
Copy link
Contributor

@analogrelay analogrelay commented Jul 24, 2019

When detailed errors is off (because Environment is not Development) and you have a startup error and .CaptureStartupErrors is one, this is what you get now:

image

I checked IIS and the Diagnostics error page. They look good already. IIS shares the page but only ever renders it if detailed errors are enabled (via Environment or the environment variable override).

Fixes #12516

@analogrelay analogrelay added this to the 3.0.0-preview8 milestone Jul 24, 2019
@analogrelay analogrelay changed the title fix #12516 by cleaning up error page fix #12516 by cleaning up capturestartuperrors error page Jul 24, 2019
@analogrelay analogrelay changed the title fix #12516 by cleaning up capturestartuperrors error page fix #12516 by cleaning up Hosting error page Jul 24, 2019
@@ -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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Always nice to make the grass greener for the next person to work with the error page!

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed. Even on platforms without powershell, you can look at the script to see how the generator is supposed to be invoked.

@@ -31,12 +31,11 @@
@foreach (var errorDetail in Model.ErrorDetails)
{
<div class="titleerror">@errorDetail.Error.GetType().Name: @{ Output.Write(HtmlEncodeAndReplaceLineBreaks(errorDetail.Error.Message)); }</div>
@{
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This wasn't valid Razor syntax, it spit out errors generating the code. I think Razor is nice and decides to work around the error but it's not actually correct.

The </div> ended the markup block so you're back in the body of the foreach which is a code context, and @{ isn't needed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did it give an error when you compiled it?

Copy link
Contributor Author

@analogrelay analogrelay Jul 25, 2019

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. It throws an error but still generates the output. But errors are bad :).

@analogrelay analogrelay requested a review from halter73 as a code owner July 25, 2019 00:04
// 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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is necessary since the property defaults to false. I thought about defaulting it to true but I think it's better for users of the page to opt-in to detailed information.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked the diagnostics one. It's a little deceptive because it's actually a different error page because it's even more detailed (query strings, headers, etc.) and the middleware is only enabled in Development mode.

I did miss GenericWebHostedService. Looking at that now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually it was the other way around :). I missed the WebHost one. Updated.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, clarify why you don't need to updat ethe GenericWebHostedService model?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@analogrelay analogrelay added the tell-mode Indicates a PR which is being merged during tell-mode label Jul 25, 2019
@analogrelay analogrelay requested a review from jkotalik July 25, 2019 00:29
@analogrelay
Copy link
Contributor Author

analogrelay commented Jul 25, 2019

Ping. Would like re-review after some changes.

@@ -0,0 +1,45 @@
{
"solution": {
"path": "C:\\Code\\aspnet\\AspNetCore\\src\\Middleware\\Middleware.sln",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make relative

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oof, good catch.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's unfortunate that the default VS experience for this doesn't use relative paths, even though they are supported. I may file a VS feedback item for that ;).

@analogrelay analogrelay merged commit cac5184 into master Jul 25, 2019
@analogrelay analogrelay deleted the anurse/12516-error-page-clean-up branch July 25, 2019 20:01
@amcasey amcasey added the area-hosting Includes Hosting label Jun 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-hosting Includes Hosting tell-mode Indicates a PR which is being merged during tell-mode

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Runtime error page leaks information about the hosting environment

6 participants