views:

427

answers:

2

I am completely puzzled with this:

I have a custom SharePoint site with QuickLaunch on the left and Top Navigation Bar (which are of course visible by default).

This custom site has several sub-sites, which all inherit navigation from the root site.

Everything works fine, but after application pool recycle both menus on the left and on top are dissapearing when I enter any of the sites for the first time! After simple refresh everythink is back to normal, all menus are visible.

After recreating the site and subsites they behave the same: on first visit - menus are not visible, after refresh they are visible and they stay visible until I make an application pool recycle.

Sometimes only one menu (top bar or quick launch) dissappers and the second one is normally visible, and I also think I encoutered a situation when it dissappeared during normal using of the site, not after the recycle.

There is nothing in the EventLog. There is a trace in the ULS log, though. When quick launch or top bar dissappears only one new line (yes, only this one, no stack trace or any further information) is added:

02/05/2010 10:24:19.18 w3wp.exe (0x171C) 0x17BC Windows SharePoint Services General 8kh7 High Cannot complete this action. Try again.

Well, indeed it says that something is wrong that is causing the menu to dissapear. Can anyone help me how to diagnose this or maybe knows why these menus are dissaparing?

A: 

Gylo do you have the Publishing feature enabled on those sites? This is a known situation when restoring saved site templates with publishing enabled (using a small hack) where the Top Navigation won't appear for the first time.

What version are you running? (Site Actions => Site Definitions shows it)

F.Aquino
No, the publishing feature is disabled. It's on MOSS 2007.You said this is a "known situation", do you have any links or resources? Maybe it's something similar.
Gylo
The 'known situation' happens when you do what I said (save a publishing site as a template, which is not allowed -- you need to use a small trick, and then restoring the site -- the menu will come broken and be fixed on the next refresh and on)
F.Aquino
OK, thanks for some clue, but I create the site and its subsited from a regular template (ONET.XML file) which is a simple template, with no extra features like publishing enabled.
Gylo
A: 

It may be that you messed with Navigation in site definition and removed Navigation Node with Id of 1002. This node is responsible for storing web Top Navigation, and even if your web uses shared navigation, you'll get disappearing navigation under some circumstances. Check if your-web.Navigation.TopNavigationBar is null. If it is, that is not very simple to restore node #1002. Below is a patch I've written to fix this issue on production environment. Test it first!

    public override void FeatureActivated(SPFeatureReceiverProperties properties)
    {
        SPSite site = properties.Feature.Parent as SPSite;

        using (SPWeb web = site.OpenWeb("/information"))
        {
            if (web.Navigation.TopNavigationBar == null)
            {
                List<SPContentDatabase> contentdatabases = new List<SPContentDatabase>();

                SPSecurity.RunWithElevatedPrivileges(delegate()
                {
                    SPNavigationNode node = new SPNavigationNode("", web.ServerRelativeUrl, false);

                    web.AllowUnsafeUpdates = true;

                    try
                    {
                        SPNavigationNodeCollection navigationNodes = null;
                        navigationNodes = web.Navigation.GlobalNodes;

                        navigationNodes.AddAsFirst(node);
                    }
                    finally
                    {
                        web.AllowUnsafeUpdates = false;
                    }

                    SPContentDatabase database = site.ContentDatabase;

                    using (SqlConnection con = new SqlConnection(database.DatabaseConnectionString))
                    {
                        con.Open();

                        using (SqlCommand command = con.CreateCommand())
                        {
                            command.CommandText = string.Format(@"UPDATE NavNodes
                            SET Url='', Eid={0}, ElementType=1, DocId=NULL
                            WHERE Eid={1}
                                and WebId='{2}'
                                and SiteId='{3}'",
                                1002,
                                node.Id,
                                web.ID.ToString(),
                                site.ID.ToString()
                            );

                            command.ExecuteNonQuery();
                        }
                    }
                });
            }
        }
    }
diamond