Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use multiple .sitemap files in ASP.NET

I think I'm missing something obvious about sitemaps.

I'm trying to use a repeater to generate some navigation for a new sitemap we have on our site. But I don't want to use our normal Web.sitemap file, I want to use our new one...we'll call it "Web.NEW.sitemap".

The code seems somewhat obvious to a 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 thought adding an attribute like:

SiteMapProvider="Web.NEW.sitemap"

ought to do it, but no dice.

What am I missing?

like image 951
Beska Avatar asked May 27 '09 16:05

Beska


1 Answers

You have to configure your web.config properly to make use of 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's name from the web.config file.

SiteMapProvider="newProvider"
like image 152
Greg Avatar answered Nov 13 '22 16:11

Greg