Source to the StaticSiteMapProvider and XmlSiteMapProvider (and others) availible for download.

I might be more excited about this than I was about the Web Application Projects preview we just released…

One of the last things I worked on in the ASP.NET runtime test team was validating a version of the sources of our providers so that users could download them and see first hand what our design practices are.  That work is finally availible to you.

I spend a large portion of my blogging efforts and forum responses trying to promote good designs or revealing little snippets of how we implemented the StaticSiteMapProvider and the XmlSiteMapProvider.  Now, the sources for these providers are availible for download all ASP.NET users and users can see examples of well written providers or copy the code to help bootstrap their own projects.

Download here:
More Info here:

One note: Functionally these providers are nearly equivelent to those actually in the framework, but because they occasionally used some internal APIs, we had to alter a few calls to use public methods instead as well as some other minor changes.

Comments (4)

  1. Serioga says:


    sorry not for a very appropriate place to post my question, by after downloading provider sources i was inspired to write my own provider. Let’s say I named it PathProvider and it is assimple as:

    public class PathProvider : StaticSiteMapProvider


       private SiteMapNode node;

       private SiteMapNode rootNode;

       private SiteMapNode parentNode;

       public PathProvider()

       { }

       public override SiteMapNode BuildSiteMap()


           lock (this)



               rootNode = node = CreateNode("root", "Home", "default.aspx");

               base.AddNode(node, null);

               parentNode = node;

               node = CreateNode("test1", "Test 1", "test1.aspx");

               base.AddNode(node, parentNode);

               parentNode = node;

               node = CreateNode("test2", "Test 2", "test2.aspx");

               base.AddNode(node, parentNode);


           return rootNode;


       protected override SiteMapNode GetRootNodeCore()



           return rootNode;


       protected virtual SiteMapNode CreateNode(string key, string url, string title)


           return new SiteMapNode(this, key, url, title);



    So, as you can see it’s very primitive, After this I added the following snippet to the web.config:

    <siteMap defaultProvider="PathProvider">



                   <add name="PathProvider" type="PathProvider"/>



    And finally I added to one of my pages SiteMapPath control:

    <asp:SiteMapPath ID="pathMenu" SiteMapProvider="PathProvider" runat="server" />

    But after all, SiteMapPath control is not visible (or better to say, is not being rendered). What I’m doing wrong?

  2. dannychen says:

    The most common reason why the SiteMapPath control would not be visible is that the CurrentNode didn’t resolve.  You can debug this two ways.  1) Set a breakpoint in CurrentNode (may need to override it) in your provider and start tracing the calls (stepping in) to see how your provider is responding  2) Add a SiteMapDataSource and a TreeView control to get an overall picture of what the data is being returned from your provider.  You may find that you see nothing in the TreeView in which case you’ll need to debug your provider in more detail.

  3. Serioga says:

    Well, Treeview and Menu controls produce correct items (and they are visible), but that not true for SiteMapPath 🙁

    Any ideas, Danny?

  4. dannychen says:

    This is exactly the scenario I was describing above.  The reason that the SiteMapPath does not show is that SiteMap.CurrentNode is returning nothing.  There is probably a coding error in your provider.  You can prove this by calling SiteMap.CurrentNode form Page_Load and looking at the return value.  I suggest that you put a breakpoint in the CurrentNode function in your provider (override it if there isn’t and just call into the base) and Trace the calls.  That is the best way to find out what is happening.