How to use multiple .sitemap files in ASP.NET

I think I'm missing something obvious in Sitemaps.

I am trying to use a repeater to create some navigation for the new site map that we have on our site. But I do not want to use our regular Web.sitemap file, I want to use our new ... we will call it "Web.NEW.sitemap".

The code seems somewhat obvious to the point ...

<asp:Repeater ID="rptMyRepeater" DataSourceID="mySitemap" runat="server"> <ItemTemplate> blah blah blah </ItemTemplate> </asp:Repeater> <asp:SiteMapDataSource ID="mySitemap" runat="server" /> 

But how do I get SiteMapDataSource to use Web.NEW.sitemap instead of the default sitemap? I was thinking of adding an attribute like:

 SiteMapProvider="Web.NEW.sitemap" 

should do it, but not cubes.

What am I missing?

+4
source share
1 answer

You must properly configure your web.config to use the SiteMapDataSource property. Use the SiteMap element :

 <siteMap defaultProvider="oldProvider"> <providers> <clear /> <add name="oldProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="web.sitemap" /> <add name="newProvider" type="System.Web.XmlSiteMapProvider" siteMapFile="Web.NEW.sitemap" /> </providers> </siteMap> 

and then set the SiteMapProvider property to the provider name from the web.config file.

 SiteMapProvider="newProvider" 
+9
source

All Articles