Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom 404 page returning 200 status code #14000

Closed
mattwootton opened this issue Mar 22, 2023 · 3 comments
Closed

Custom 404 page returning 200 status code #14000

mattwootton opened this issue Mar 22, 2023 · 3 comments
Labels

Comments

@mattwootton
Copy link

Which Umbraco version are you using? (Please write the exact version, example: 10.1.0)

11.2.1

Bug summary

In the latest Umbraco 11 version we have noted that custom 404 pages set through the "Error404Collection" content setting via appsettings.json return a 200 status code rather than 404. This was first picked up due to redirects added via the Skybrud Redirects package were not working and we determined this was due to the page returning a 200 status code.

The default Umbraco 404 page template does return a 404 status code but if you provide your own custom page the status code instead returns a 200 for any missing page.

Obviously we can manually set the status code in the template of the page configured for the 404 page but ideally this should be automatic and I believe this as the case in v10 and earlier versions of Umbraco.__

Specifics

Example sites:
https://www.themoleresort.co.uk/nothere
https://www.sprintvalley.com/nothere (this is an Umbraco Cloud site)

Steps to reproduce

  1. Configure a custom 404 page via the "Error404Collection" in appsettings.json
  2. Attempt to view a page on the site that doesn't exist
  3. Note the custom 404 page is shown but that the response status code is 200

Expected result / actual result

Expect the status code to be 404

@github-actions
Copy link

Hi there @mattwootton!

Firstly, a big thank you for raising this issue. Every piece of feedback we receive helps us to make Umbraco better.

We really appreciate your patience while we wait for our team to have a look at this but we wanted to let you know that we see this and share with you the plan for what comes next.

  • We'll assess whether this issue relates to something that has already been fixed in a later version of the release that it has been raised for.
  • If it's a bug, is it related to a release that we are actively supporting or is it related to a release that's in the end-of-life or security-only phase?
  • We'll replicate the issue to ensure that the problem is as described.
  • We'll decide whether the behavior is an issue or if the behavior is intended.

We wish we could work with everyone directly and assess your issue immediately but we're in the fortunate position of having lots of contributions to work with and only a few humans who are able to do it. We are making progress though and in the meantime, we will keep you in the loop and let you know when we have any questions.

Thanks, from your friendly Umbraco GitHub bot 🤖 🙂

@abjerner
Copy link
Contributor

abjerner commented Mar 22, 2023

Just for reference, this bug was introduced in 11.2.0, and a fix is scheduled to be released in 11.3.0.

My issue can be seen here: #13907

The issue can be hotfixed by manually setting the status code to 404 - eg. in the template of the 404 page:

if (Model.Key.ToString() == "a04bff52-4ca8-43d3-a5f0-7c7f4b071352") {
   Context.Response.StatusCode = 404;
}

In this example, the 404 page could be a normal page that happen to be used as the 404 page, so checking against the key allows us to only set the status code for the 404 page, and not other pages using the same template.

@mattwootton
Copy link
Author

Ah, thanks for making me aware.

Hadn't spotted that and it didn't show up in a search of the issue tracker but think I was only searching open issues and yours has been closed.

Yep we are able to manually update but it's a pain as like you we are using a standard template for the 404 page that is used by other pages.

I'll close this down then as good to hear a fix is already underway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants