ScioSoft's Community Blogs Optimized IT musings for the technically inclined

Referencing external URLs in your web.sitemap in ASP.NET

by James Fielding 23. February 2010 09:57

In ASP.NET, we often use site maps to set up navigation, particularly for menus. By default, the ASP.NET  site-map provider  uses the "Web.sitemap" file. Here is an example of this file for a simple site:

<?xml version="1.0" encoding="utf-8" ?>
    <siteMapNode title="Home" description="Home" url="~/default.aspx">
        <siteMapNode title="Services" description="Services we offer" url="~/Services.aspx">
            <siteMapNode title="Consulting" description="Consulting services" url="~/Consulting.aspx" />
            <siteMapNode title="Support" description="Supports plans" url="~/Support.aspx" />
        <siteMapNode title="About Us" description="About Us" url="~/AboutUs.aspx">
            <siteMapNode title="Company" description="Our people and offices" url="~/Company.aspx" />
            <siteMapNode title="Blogs" description="Blogs from us to you"
              url="" />

So our basic menu will look like this:

    About Us

Notice that the "Blogs" node in the "About Us" section references an outside URL. This is not a problem, until you start adding role-base security to the site. Specifically, once you set you securityTrimmingEnabled="true" in the Web.config or the Web.sitemap file, the "Blogs" node disappears, and you're left scratching your head.

    About Us

At this point, you'll find that some developers get rid of the web.sitemap, and start hard coding menu items. However, there is a really easy fix for this behaviour. Just allow everyone access to the Blogs node so that it doesn't get trimmed:

<siteMapNode title="Blogs" description="Blogs from us to you"
    url="" roles="*">

By adding roles="*", we've got our blog back. That was almost too easy.

Just for completeness, I'm going to mention that we could have also just disabled the security trimming in the Web.sitemap file by adding securityTrimmingEnabled="false" to the Blogs node. Although I'm not a big fan of this method, as I find it makes the Web.sitemap less clear on what we're trying to accomplish, which is never good for the next guy working on the site, but the choice is yours.

Happy referencing,
James Fielding

kick it on

Sciosoft Systems is a Canadian web design & development company based in Muskoka, which is in central Ontario. We provide ASP.NET website & Windows Server application development services to small and medium-sized business, as well as local government and not-for-profit groups. If you have a website project you’d like to discuss, please visit us at

Share |

Tags: , ,

Web Development | ASP.NET

Comments (2) -

Gedichte United States
5/18/2010 9:01:28 PM #

Hello from Germany! May i quote a post a translated part of your blog with a link to you? I've tried to contact you for the topic Referencing external URLs in your web.sitemap in ASP.NET, but i got no answer, please reply when you have a moment, thanks, Gedichte

ScioJim Canada
5/20/2010 8:51:30 PM #

Hi Gedichte. Typically, it's an honor to be quoted. Of course, just copying an entire article is not good, even if it is a translation. Please use the contact us form at to discuss details.


Pingbacks and trackbacks (1)+

Comments are closed


Comment RSS

The opinions expressed herein are the personal opinions of the contributors and do not necessarily represent the views of Sciosoft Systems Inc.