Sitemap randomly breaks over time Sitemap randomly breaks over time asp.net asp.net

Sitemap randomly breaks over time


I put a previous post on this thread that got deleted :( anyhow I 'had' the same problem.

I found that no matter what I did the "Could not find the sitemap node with URL '~/rootnode" occurred. My break came when I decided to remove the file system dependency and switch to the SqlSiteMapProvider from wicked code. I found that this problem was more reliably re-created.

In short you get that message because there is no site map! I found that on the site map data source if you use the StartingNodeUrl="~/root.htm" then the error message will appear when there is no sitemap built. However if you use StartingNodeOffset="0" then the error message is not displayed and there simply is no menu rendered when the sitemap is not built.

Seemed strange to me but I traced it back to the XmlSiteMapProvider. Sometimes it built sometimes it didn't. Couldn't get my head fully under the bonnet but it looked like something happening Asynchronously. Anyhow I've switched to the SqlSiteMapProvider from wickedcode.

One change I made, aside from converting to vb was to put a recursive call on the return of the overridden BuildSiteMap method:

' Return the root SiteMapNodeIf _Root Is Nothing Then   Return Me.BuildSiteMapElse   Return _RootEnd If

This makes sure the sitemap builds. I thought about putting an infinite recursion guard in but it doesn't seem to be required.

I'm still thinking that perhaps a network lag or some authentication (which at our place is through an AD controller, and lags first thing in the morning !!) is what is making the XmlSiteMapProvider miss it's Async build window?

Really hope this helps.


Hmm. Its been a couple of years since I worked with ASP.net, but if I recall, I had a similar problem which I solved with

Page.ResolveURL("~SomePage.aspx");

At runtime the sitemap urls are resolved to the actual url, so the tilde is removed and replaced with the actual URL (I think :) ).


I have two possible ideas for this problem. Neither is guaranteed to work. ;-)

  1. Is it possible that you are also using URL Authorization at the sametime in some of your web.config files located in various foldersthroughout your web application?

    Example URL Authorization setting that could be found in oneweb.config file:

    <location path="bobsSecret.aspx">     <system.webServer>         <security>             <authorization>                 <remove users="" roles="BobAndFriends" verbs="" />                 <add accessType="Allow" users="Bob" />                      </authorization>         </security>     </system.webServer> </location> 

    The reason I mention this is I had some trouble in the past tryingto get the roles property in my sitemap XML file to work correctlywith the settings I had applied in my URL Authorization in a web.config.

    The only thing I could imagine would be some sort of race conditionwhere the process responsible for enforcing these policies isreading one security setting in one place (web.config) beforereading it in another place (web.sitemap).

    Just a stab in the dark, based off some past issues I hadexperienced!

  2. As a second option, you could consider putting this configuration inyour aspx page instead of in the Page_Load event on the code behind.You could try this:

    <asp:SiteMapDataSource    id="SiteMapDataSource1"    runat="server"    StartingNodeUrl="~/Default.aspx"></asp:SiteMapDataSource>

    This way your StartingNodeUrl is specified in the ASPX page itself, and if this is truly an intermittent bug in the Framework code, perhaps this slight change might fix the problem.