umbraco / UmbracoDocs

The official Umbraco Documentation
https://docs.umbraco.com
MIT License
266 stars 770 forks source link

Docs for handing error pages are not ideal #6420

Open ctolkien opened 1 week ago

ctolkien commented 1 week ago

What type of issue is it? (Choose one - delete the others)

Wrong documentation

What article/section is this about?

(link here)

Describe the issue

This section describes intercepting the 500 error response and then redirecting the user to a page to display the error. In this scenario statuscode is lost, and the user never actually receives a 500 error, they end up receiving a 3XX redirection.

This should probably be using some combination of app.UseExceptionHandler("..."); and app.UseStatusCodePagesWithReExecute("/error/{0}");

sofietoft commented 1 week ago

Thanks for reporting this @ctolkien ! 💪 Much appreciated!

Now, this might be a stupid question, so please forgive me, but isn't it in most cases better for the user to not see the error, than for them to see it? 😅

In any case, would you be up for suggestion a rewrite of this guide, to include your suggestions? Sounds like you already have some experience with this, and might know how it could be set up differently.

ctolkien commented 1 week ago

Now, this might be a stupid question, so please forgive me, but isn't it in most cases better for the user to not see the error, than for them to see it?

Yep, to be clear, the issue is not the content that is shown. It is that the current flow is:

When a user hits an error, ideally the URL does not change, they should get the error on the same URL they are on, showing the error content, but at the current URL with a 500 status code.

In any case, would you be up for suggestion a rewrite of this guide, to include your suggestions? Sounds like you already have some experience with this, and might know how it could be set up differently.

Yes, let me do a bit more digging on handling the use cases. There are some further considerations, for instance you ideally want to have the 500 page be static content and not be rendered via the CMS. If there is an issue in your Layout file (for instance), which means that no page can work - including the 500 page, then your user will not see the properly rendered 500 page. By having it be as simple as possible, with no dependencies, that would be the most reliable option.

sofietoft commented 1 week ago

Aha, yes, I see what you mean 🤔 By using the redirect method the context is lost and what they're seeing is actually "okay".

It would be great if you could suggest a better method here! I like the idea with using a static page - that should always be available to show, at least in some form!

Hacktoberfest starts next month, and this sounds like a perfect little side task for that 😄