SharePoint QuickLaunch and TopNavigationBar disappear

I am completely puzzled by this:

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

This user site has several sub-sites that all inherit navigation from the root site.

Everything works fine, but after reusing the application pool, both menus on the left and on the top disappear when I enter any of the sites for the first time! After a simple update, everything returns to normal, all menus are visible.

After the site and sub-sites are recreated, they behave the same: on the first visit, the menus are not visible, after the update they are visible and remain visible until I restart the application pool.

Sometimes only one menu (top bar or quick launch) disappears, and the second is normally visible, and I also think that I encountered a situation where it disappeared during normal use of the site, and not after a reboot.

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

05/02/2010 10: 24: 19.18 w3wp.exe (0x171C) 0x17BC Windows SharePoint Services General 8kh7 High This operation cannot be completed. Try again.

Well, indeed, it says that something is wrong that causes the menu to disappear. Can someone help me how to diagnose this or maybe know why these menus disappear?

+3
2

? ( ), .

? ( = > )

0
, Node 1002. Node - , , . , -web.Navigation.TopNavigationBar . , Node # 1002. , , . !
    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();
                        }
                    }
                });
            }
        }
    }
0

Source: https://habr.com/ru/post/1731526/


All Articles