I've been having some production runtime errors that I don't fully understand. This has happened to us on a couple different ASP.NET 4.0 Web Sites (shudders - yes, I know - we're porting it to MVC but that's taking some time).

First of all, we have never been able to reproduce this issue in development/QA environments. Secondly, upon deployment, the issue seems to be non-existent. Sometimes the issue manifests within a day or two of deployment and other times the deployment will be live for a month without it manifesting at all. However, once it manifests, then ANY page viewed under the web site causes the error. Lastly, this problem seemed to only come up once we migrated to .NET 4.0. We started at 2.0, a year ago upped to 3.5, and recently upped to 4.0 with this solution and most child projects.

The error: Could not find the sitemap node with URL '~/Default.aspx'.

A simplified version of our sitemap (with some names changed and uninteresting nodes removed) is as follows:

<siteMap xmlns=""&gt;
   <siteMapNode roles="*" title="EG">
      <siteMapNode url="~/../SM/Default.aspx" title="Welcome" description="" roles="*" />
      <siteMapNode url="~/../SD/Default.aspx" title="SD" description="" roles="*" />
      <siteMapNode url="~/../SMD/Default.aspx" title="SMD" description="" roles="*" />
      <siteMapNode url="~/Default.aspx" title="Ops" description="" roles="*" >
         <siteMapNode url="~/Error.aspx" title="Error" hide="true" roles="*" />
         <siteMapNode url="~/Public/Login.aspx" hide="true" roles="*" />
         <siteMapNode url="~/Manager/LPCE.aspx" title="LPCE" description="" roles="Administrator, Manager, System, Marketer" imageUrl="~/../SM/images/icons/LF.jpg" />
      <siteMapNode url="~/../SDD/Default.aspx" title="SDD" description="" roles="*" />
      <siteMapNode url="~/../CCD/Default.aspx" title="CCD" description="" roles="*" />
      <siteMapNode url="~/../RD/Default.aspx" title="RD" description="" roles="*"/>
      <siteMapNode url="~/../SBD/Default.aspx" title="SBD" description="" roles="*" />

It is registered in our web.config:

<siteMap defaultProvider="SDXmlSiteMapProvider" enabled="true">
    <add name="SDXmlSiteMapProvider" type="System.Web.XmlSiteMapProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="web.sitemap" securityTrimmingEnabled="true" />
    <add name="SecurityDisabledSiteMapProvider" type="System.Web.XmlSiteMapProvider, System.Web, Version=, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="web.sitemap" securityTrimmingEnabled="false" />

And from logs I have narrowed down what causes the error is in a base class that pretty much all of our pages derive from:

private void Page_Load(object sender, EventArgs e)
        SiteMapDataSource.StartingNodeUrl = "~/Default.aspx";

I have confirmed in all of the SiteMaps that there is a node with url="~/Default.aspx" with roles="*" (which includes public/anonymous access), so I am very confused as to why this problem occurs.

The problems I have considered:

  1. SiteMap does not have a node for Default.aspx. All of them do.
  2. SiteMap's Default.aspx node is not accessible for security reasons to the current user/role. They're all accessible to anonymous users and this problem even exists for super admin users.
  3. Passed-in URL contains querystrings (Default.aspx?abcd). I don't know if this is a problem (I sure would hope not) but once the problem manifests itself, I can handwrite the URL with no querystrings and the problem still exists.
  4. SiteMap changes. It doesn't
  5. Service's permissions to the sitemap file. The sitemap works perfectly fine after a deployment, so unless permissions are changed in a way that IISRESET fixes, then this is not an issue.
  6. The worker process becomes globally corrupt. I don't think so. We have ~12 web sites all in the same app pool and the problem always stays confined within a single web site. Also, we have yet to have this happen to more than a single web site at a time although it has manifested itself in 4 different ones so far.

Can anybody shed some light on this? It almost seems as though the dynamically-compiled SiteMap gets corrupted or something. The only resolution I have found is an IISRESET or equivalent. And even then, there's no telling as to how long the problem will be resolved. This is VERY frustrating!