There is a limitation with sitemap that URL for nodes should be unique. There are situations when we require multiple nodes to redirect to same page. If two nodes with same URL are found then error will be thrown.
As discussed there is a limitation that multiple nodes with same URL cannot be added in the sitemap otherwise it throws error (Error occurs while running AddNode method). Reason of this limitation is – Sitemap uses the URL to add new entry in the internally created Hashtable. URLs are used a keys for the items. As keys need to be unique so do the URLs. But there is a loophole in this. What about the nodes which have empty URLs? Yes, there is the catch. For such nodes sitemap generates a key itself which will be unique. So we can use the same thing. Once we have generated the URL, we can store it in some temporary variable, we can add the new node, again change it (yippieeeeee! It works)
protected override void AddNode(SiteMapNode node, SiteMapNode parentNode)
string tempURL = node.Url;
node.Url = “”;
node.Url = tempURL;
catch (Exception ex)