Friday 24 May 2013

SharePoint 2010 Corrupt Navigation Nodes


Symptoms:

  • Response was extremely slow
  • Only affecting a single Site Collection
  • No errors in the Event Viewer
  • Still able to browse the site structure through SharePoint Designer
  • Errors on the screen said something like:
    • Error occurred while rendering navigation requested url
    • An unexpected error occured while manipulating the navigational structure of this Web.
  •  Noticed that, when a page did load, it had dozens (hundreds?) of Navigation nodes on Current navigation and Global Navigation


Suspected Cause: 

Thought that maybe the reason this was taking so long to load a page, was that the Navigation is corrupt and it was trying to build out this enormous navigation structure.

To fix:

Open PowerShell on the server, check the size of those objects at the top level:

$siteUrl = "http://WebAppURL/sites/scname"
$spWeb = Get-SPWeb $siteUrl
$spWeb.Navigation.QuickLaunch | ft Title
$spWeb.Navigation. TopNavigationBar | ft Title

  
Then, if this looks like the problem, delete the QuickLaunch Nodes, then delete the TopNavigationBar Nodes, as required:


$siteUrl = "http://WebAppURL/sites/scname"
$spWeb = Get-SPWeb $siteUrl
    Foreach($node in ($spWeb.Navigation.QuickLaunch))
{
    write-host "The node title is "$node.Title
    $node.Delete()
}
$spWeb.Dispose()



$siteUrl = "http://WebAppURL/sites/scname"
$spWeb = Get-SPWeb $siteUrl
    Foreach($node in ($spWeb.Navigation.TopNavigationBar))
{
    write-host "The node title is "$node.Title
    $node.Delete()
}
$spWeb.Dispose()


Note that I had to run these commands several times.  It looked like it would delete 80% of them, then get an error.  If this happens, then just run it again:
PowerShell error when running the above command
Add caption