Umbraco-CMS icon indicating copy to clipboard operation
Umbraco-CMS copied to clipboard

Error404Collection not used when node exists but without template

Open bjarnef opened this issue 2 years ago • 5 comments

Which exact Umbraco version are you using? For example: 9.0.1 - don't just write v9

9.4.1

Bug summary

We have a few archive nodes, which by default have generated URL's

When accessing these pages e.g. /products we get the default 404 page.

image

However when we access a non-existing node like /test is does show our custom 404 page.

"Error404Collection": [
{
    "Culture": "en",
    "ContentKey": "7b52eeef-883d-4483-8e59-d9442485bfa3"
}]

Specifics

No response

Steps to reproduce

Create a few nodes without templates and configure a custom 404 page via Error404Collection in appsettings.json

Access a random non-existing page e.g. /test - this should show the custom 404-page.

Access a node with a generated URL but without a template, e.g. /products - this show the default 404-page.

It may be related to this issue https://github.com/umbraco/Umbraco-CMS/issues/12182 but the node hasn't been renamed or redirects been created.

Expected result / actual result

No response

bjarnef avatar Apr 06 '22 07:04 bjarnef

Sounds like this is related to #12002?

nathanwoulfe avatar Apr 06 '22 08:04 nathanwoulfe

@nathanwoulfe possible...

I checked on another project on v9.2.0 .. where it throws 500 internal server error instead.

bjarnef avatar Apr 06 '22 11:04 bjarnef

Any updates on this? Or any workarounds as I'm using Umbraco without templates on all nodes (except root) so I'm a bit stuck.

bineagu avatar May 30 '22 14:05 bineagu

My workaround is to create a content finder which wraps the existing content finders

		public async Task<bool> TryFindContent(IPublishedRequestBuilder request)
		{
			if(await _finderByUrl.TryFindContent(request) || await _finderByIdPath.TryFindContent(request))
			{
				if (request.PublishedContent.TemplateId == null)
				{
					request.SetPublishedContent(null);
					return false;
				}
				// other custom stuff here
				if (TryRedirectToCanonical(request))
				{
					return true;
				}
				return true;
			}
			return false;
		}

Myster avatar Jul 19 '22 22:07 Myster

NB: still an issue in 10.0.1

Myster avatar Jul 19 '22 22:07 Myster

Hey all, sorry for the late reply.

Checking this out in the latest V10, this issue seems to have been resolved, probably by https://github.com/umbraco/Umbraco-CMS/pull/12002, so I'll go ahead and close this as solved 😄

nikolajlauridsen avatar Jan 05 '23 08:01 nikolajlauridsen