Multiple Sitemaps

Globalization

A problem that i found lately was when i needed to have multiple sitemaps. Why? I needed different menus for different parts of the website. Normally, the sitemap must be found at the root of the website. After searching, I found this solution which is very easy to implement… Next are the steps:

1. In web.config, you can add multiple site map providers, and set the siteMapFile property.

    <siteMap defaultProvider=”XmlSiteMapProvider” enabled=”true”>
      <providers>
        <add siteMapFile=”web.sitemap” name=”XmlSiteMapProvider” type=”System.Web.XmlSiteMapProvider” securityTrimmingEnabled=”true”/>

 <add siteMapFile=”my.sitemap” name=”MyXmlSiteMapProvider” type=”System.Web.XmlSiteMapProvider” securityTrimmingEnabled=”true”/>

      </providers>
    </siteMap>

2 In a page, add a SiteMapDataSource, set the SiteMapProvider to you have configurated in the config file

<asp:SiteMapDataSource ID=”SiteMapDataSource1″ runat=”server” SiteMapProvider=”MyXmlSiteMapProvider” />

3. Bind you treeview or menu control to this datasource control.

2 Responses

  1. I found many articles and threads about it, but I completely understand only this explanation. Thank you very much.

Leave a Reply

Your email address will not be published. Required fields are marked *