Share via


Update to "Site Navigation System in ASP.NET 2.0"

My blog back in August 2005, entitled “The Site Navigation System in ASP.NET 2.0 – My First MSDN Article”, described the structure of the site navigation system in ASP.NET 2.0, and how you could build you own provider.

John from SiliconZone has been in touch with me to point out a minor bug that he has rectified, so here is his update – many thanks John!
 
OK, I finally figured it out... You need to change the FindSiteMapNode() method to be similiar to the following:

    public override SiteMapNode FindSiteMapNode(string rawUrl)
{
if (urlHash.ContainsKey(rawUrl))
{
SiteMapNode n = (SiteMapNode)urlHash[rawUrl];
return n;
}
else
{
if (keyHash.ContainsKey(rawUrl))
{
SiteMapNode n2 = (SiteMapNode)keyHash[rawUrl];
return n2;
}
else
{
return null;
}
}

Apparently, when the tree is expanding, it is giving you the URL without the page name (ie, default.aspx)... this method must be changed to include both hash lookups!