Under the covers, the SiteMapDataSource control represents the contents of the SiteMap class.
File: Global.asax
<%@ Application Language="C#" %>
<%@ Import Namespace="System.IO" %>
<script runat="server">
void Application_Start(Object sender, EventArgs e)
{
SiteMap.SiteMapResolve += new SiteMapResolveEventHandler(SiteMap_SiteMapResolve);
}
SiteMapNode SiteMap_SiteMapResolve(object sender, SiteMapResolveEventArgs e)
{
if (SiteMap.CurrentNode == null)
{
string url = e.Context.Request.Path;
string title = Path.GetFileNameWithoutExtension(url);
SiteMapNode newNode = new SiteMapNode(e.Provider, url, url, title);
newNode.ParentNode = SiteMap.RootNode;
return newNode;
}
return SiteMap.CurrentNode;
}
</script>
File: Web.sitemap
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
<siteMapNode
url="Default.aspx"
title="Home"
description="The Home Page">
<siteMapNode
url="Default1.aspx"
title="Our Products"
description="Products that we offer">
<siteMapNode
url="FirstProduct.aspx"
title="First Product"
description="The description of the First Product" />
<siteMapNode
url="SecondProduct.aspx"
title="Second Product"
description="The description of the Second Product" />
</siteMapNode>
<siteMapNode
url="Default2.aspx"
title="Our Services"
description="Services that we offer">
<siteMapNode
url="FirstService.aspx"
title="First Service"
description="The description of the First Service"
metaDescription="The first service" />
<siteMapNode
url="SecondService.aspx"
title="Second Service"
description="The description of the Second Service" />
</siteMapNode>
</siteMapNode>
</siteMap>