Alex Rivera | Logout

Sitemap randomly breaks over time

Asked 2010-08-02T17:37:19.203
11

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="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0">
   <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>
      <siteMapNode url="~/../SDD/Default.aspx" title="SDD" description="" roles="*" />
   
Edit
Report

2 Answers

0

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 :) ).

answered 2010-11-29T10:06:56.523
0

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 same time in some of your web.config files located in various folders throughout your web application?

    Example URL Authorization setting that could be found in one web.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 trying to get the roles property in my sitemap XML file to work correctly with 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 condition where the process responsible for enforcing these policies is reading one security setting in one place (web.config) before reading it in another place (web.sitemap).

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

  2. As a second option, you could consider putting this configuration in your 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.

answered 2011-09-15T16:37:08.380

Your Answer