Thursday, October 04, 2007 4:07 AM
By default, ASP.NET comes with a default SiteMap provider which expects a file called Web.sitemap to be in your project. This is great if you only want one file, but what if you want multiple sitemap files? Implementing this functionality is pretty easy:
Add the below code to your web.config file within the System.Web tag. This creates a new "provider" that you can specify for a SiteMapDataSource control to tell it to look for a different sitemap file.
<siteMap enabled="true">
<providers>
<add name="MyNewSitemapProvider"
type="System.Web.XmlSiteMapProvider"
siteMapFile="MyNewSitemapFile.sitemap"/>
</providers>
</siteMap>
Then in the markup for your SiteMapDataSource, just add the line to its tag:
SiteMapProvider="MyNewSitemapProvider"
This tells it to use the new provider instead of the default one.
Then just set your menu or other navigation control to point to the new SiteMapDataSource for its datasource and all should be good! You can also have as many providers listed as you want...so if you have 5 different maps that you want to make available, just add away!
D