Web.Sitemap Errors After .NET 4.0 / IIS7 Upgrade

Discussion in 'ASP.NET / ASP.NET Core' started by pinch, May 16, 2011.

  1. Since upgrading I'm seeing some strange results when querying against my web.sitemap file. Since most of my navigation is based on my web.sitemap file, this means many of my pages aren't loading.

    When I query against the web.sitemap file, I'm getting back incorrect values for the url property. So if I run the following code

    Code:
    SiteMapNode rootNode = SiteMap.Provider.RootNode;
        labTest.Text = rootNode.Url;
    
    I would expect to read back "~/default.aspx", but instead I get back:

    To make matters even stranger, the problem is sporadic even though my code hasn't changed. A snapshot of my web.sitemap is shown below:

    Code:
    <?xml version="1.0" encoding="utf-8" ?>
    <siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
        
    	<siteMapNode url="~/default.aspx" title="Fantasy Football and Racing Cheat Sheets"  description="Create customized fantasy draft cheat sheets for various fantasy sports including NFL football and NASCAR racing, or free.">
    
        <siteMapNode url="~/register.aspx" title="Register"  description="Register to unlock the full power of CheatSheetWarRoom." />
        <siteMapNode url="~/sitemap.aspx" title="Sitemap" description="View all pages of our website provided as hyperlinks for easy navigation." />
    		<siteMapNode url="~/faq.aspx" title="FAQ" description="Get answers to frequently asked questions." />
    		<siteMapNode url="~/about.aspx" title="About" description="Read about what drove the creation of our cheat sheet creation tools." />
    		<siteMapNode url="~/contact.aspx" title="Contact"  description="Contact us with any queries or suggestions you may have." />
    		<siteMapNode url="~/passwordrecovery.aspx" title="Password Recovery"  description="If you've forgot your password, validate yourself and we'll sent it to you." />
    		<siteMapNode url="~/editprofile.aspx" title="Edit Profile" description="Edit your personal profile to keep your personal information current." />
    		<siteMapNode url="~/admin/Users/UserStats.aspx?" title="Admin" roles="Administrator" description="An entry point into the administration menu." />
    
    On my local machine, everything works just fine.
     
  2. I've also found that if I change something in the web.config (such as remove the ~/ in front of the default.aspx) then re-load the page a few times, the problem will eventually vanish and the proper urls will be returned. But after some time, the problem pops up again. You may be able to see the issue here.
     
  3. ...They can be a bit buggy, and many bugs are listed on the Connect site.
    Do you have a closing tag with that or it's just missing above?
    </siteMapNode>
     
  4. Yeah I only grabbed a snippet to show that the root node was indeed "~/default.aspx". It seems to me that the '~' is being mis-interpreted, and only sporadically. I didn't see this problem with the same code running under ASP.net 3.5. I tried to copy my entire sitemap file here but got an error saying it was too long. This is a big problem for me and the fact that the problem is sporadic makes me think this has to be a server-related issue.
     
  5. Here is my web.sitemap attached as a text file.
     

    Attached Files:

  6. I'm now getting slammed with 404 errors because links from my auto-generated sitemap (from the web.sitemap file) are creating invalid links with the strange characters inserted for the ~'s when building the page links. Check out a sample of my 226 unfound pages.

    http://www.cheatsheetwarroom.com/(A...SGBpdcG4jP-xLs1))/fantasy-football-links.aspx
    404 (Not found)

    unavailable
    May 15, 2011
    http://www.cheatsheetwarroom.com/(A...de-receiver-rankings.aspx?Page=13&Position=WR
    404 (Not found)

    unavailable
    May 15, 2011
    http://www.cheatsheetwarroom.com/(A...uide-to-starting-a-league/1/introduction.aspx

    Links were shortened, but check out the full url on hover to see how that ~/ from the web.sitemap is being pre-pended with a huge cryptic string, make the pages 404s.
     
  7. The only thing I can think of is an older trick which may not help but is worth trying...
    Add an empty node as the first node, see it that changes the behavior.
     
  8. It looks like the culprit was the <urlrewritingnet> module. Apparently it doesn't jive too well with ASP.net 4.0.
     
  9. I take it back, still broken. I have been able to prove that editing the web.config in any way resolves the problem for some time, then it resurfaces again at a later time.
     
  10. I revered back to ASP.net 3.5 (still under IIS7) and the problem has gone away completely. The only thing I changed when reverting back to ASP.net 3.5 is the web.config file so now I'm at a complete loss as to how to proceed.
     
  11. Sorry to see you having so much trouble with this.
    Question...What sort of changes to the web.config made a difference?
     
  12. Any change fixes it (i.e. add a space to the web.config and re-save). My understanding is that this causes the App Pool to be recycled. After this happens I can read the web.sitemap file fine for awhile, then after some period of time (it could be after the session expires) it starts reading the strange characters again.

    This really seems to be a problem associated with how ASP.net is building paths with the '~' character. Even in my crawl error logs, for whatever reason ASP.net is substituting [a GUID?] for the '~' when building links. I've listed some crawl error urls below. You can see that the ASP.net engine tries to piece together my page paths, but instead of removing the '~' character, it inserts the cryptic string value. If you take the cryptic string value (where the tilde used to be) out the path is correct.

     
  13. Are you guys still offering sandboxes for ASP.net 4.0? It would be nice to have somewhere to debug this problem without bringing my site down.
     
  14. mjp

    mjp

    No, sorry. We always close the beta programs/sandboxes when the product releases.
     
  15. After about a year of searching I think I have found the source of this problem. It is a Microsoft bug and is explained here:

    http://stackoverflow.com/questions/5900035/sitemappath-stops-displaying-in-asp-net-4

    And the hotfix is here:

    http://support.microsoft.com/default.aspx?scid=kb;en-US;2472263

    This problem is preventing me to upgrade to ASP.net 4.0. Is there any way we can get this fix applied? I have tried to remedy the problem through my web.config settings (I'm forcing the use of cookies) but the problem persists.
     
  16. I have resolved this issue, please disregard my last post.
     

Share This Page