Skip to content

Incorrect child page sub-menus when URL ends with trailing slash #135

@JimKerslake

Description

@JimKerslake

Creating this ticket in SimpleContent for now because it relates to the sub-page child menu trees within a page hierarchy -
and I cannot replicate the same issue when running cs.Web.Navigation - but it's unclear whether the bug will be in this repo or perhaps Navigation.

In any case:
https://app.hauc-uk.org.uk/the-red-book >> full child menu
https://app.hauc-uk.org.uk/the-red-book/ >> child menu vanishes.

In other places you see a partial child menu - like the tree builder has skipped forwards / down one level.
Something is going wrong with the "starting node" that is getting passed in to the navigation tree builder, I guess.
There's probably a child tree view component that takes a starting node parameter somehow...

But re-stating - the demo nav tree within the navigation repo dev webapp does not seem to display the same bug.

Possible workaround that does not address the bug - but means that it will never be encountered:
we could configure our CS apps (in the template) such that we override the default behaviour that treats the above as 2 separate routes, and enforce that trailing slashes are rewritten out of the routing (whilst preserving any appended query strings):

          var rewriteOptions = new RewriteOptions()
             .AddRedirect("(?i)^(.+)/$", "$1", 301);// Remove all trailing slashes 

          app.UseRewriter(rewriteOptions);

Putting the above in startup, just ahead of app.UseMvc(routes =>

That seems inferior to finding the nav tree bug and addressing it though.
Unless we're sure we always want the above behaviour.

Note that the behaviour of automatically removing trailing slash at the root (home) page via a redirect is not a default property of .Net, but can be a function of IIS (Express) config in your launchSettings.json file, and that gets in the way of investigating this issue when looking at the root page - better to work with it by adding trailing slash on a subordinate page, which typically does not get auto-removed.

Metadata

Metadata

Assignees

Labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions