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

10 comments:

  1. excellent......can you please tell me what line from ULS log suggested you that there is some issue the Top and Left Nav...:)

    ReplyDelete
  2. Excellent. This helped me resolve the same issue. Not sure how it can prevented, though. The page that was causing issues for me had commas "," in the filename. I had to delete the page using SharePoint Manager in order to get the script to run faster.

    ReplyDelete
  3. Thanks you. This fixed the problem on our SharePoint farm.

    ReplyDelete
    Replies
    1. No worries Arun. Happy to be of assistance. :)

      Delete
  4. It works like a charm. Thank You.

    ReplyDelete
  5. Yes. It worked for me too. Thank you for your post.

    ReplyDelete
  6. Superb solution! worked for me too.. Thanks a lot!

    ReplyDelete
  7. thx man ! my dev was really slow because of this, gave me headach for 1 week

    ReplyDelete
    Replies
    1. actually if i run the script again it still shows me the pages, as if the db was not updated... but at least the site is not slow anymore and the navigation page is loading.

      The recommended solution is to install CU April 2013, or SP2013 SP1 ! I will give it a try

      Delete