Skip to content

SiteMap.FindSiteMapNodeFromUrl gives infinite loop when no node and embedded in an aspx page #366

@MikeWalsh

Description

@MikeWalsh

This might be a bit of an edge case here but after updating to v4.6.15
In older parts of the site we are rendering the sitemap using a mvc partial embedded in an aspx page.
We have very large quantities of non-public accessible urls so don't want to create nodes for each.
When SiteMap.FindSiteMapNodeFromUrl is called on a url that doesn't exist in the sitemap line 747 gives

string clientQueryString = currentHandler.ClientQueryString;
if (clientQueryString.Length > 0)
{
    node = this.FindSiteMapNode(relativePath + "?" + clientQueryString);
}

This call to FindSiteMapNode then calls FindSiteMapNodeFromUrl again which ends up in a stack overflow.
I changed that code to

string clientQueryString = currentHandler.ClientQueryString;
if (clientQueryString.Length > 0)
{
    string newSearchTerm = relativePath + "?" + clientQueryString;
    // avoid infinite loops
    if (newSearchTerm != relativeUrl)
    {
        node = this.FindSiteMapNode(newSearchTerm);
    }
}

and all seems to be well again

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions