I am trying to add a new navigation node to Top Navigation bar in my sharepoint website and I am using the following code:
public void AddNavigation(SPWeb web, String url, string module, string key)
{
var resourceFile = "$Resources:" + module + "," + key;
UnregisterGlobalNavigationLink(web, url);
SPNavigationNode node = web.Navigation.GetNodeByUrl(url);
if (node != null && overrideGlobalNavigationSetting) return node;
node = new SPNavigationNode(resourceFile, url);
node = web.Navigation.TopNavigationBar.AddAsLast(node);**//Exception here**
}
But I am getting an exception that I don't know how to resolve:
An unexpected error occured while manipulating the navigational structure of this Web.
How can I solve this issue?
If it is an external node you want to add a another parameter
isExternal = true
to the node constructor, so it looks like this:EDIT: And by external I mean it points outside the site collection