Ranjanmano
Ranjanmano

Reputation: 135

How to read url path form sitemap in ASP.NET Sitemap file?

I have a sitemap file and it is addressed in the web.config sitemap provider. I want to get the get the URLs of the pages included in the sitemap, so that I can process them and index those pages for searching. The URLs are relative. How to implement the code in the codebehind file? Is it possible to read the URLs from the codebehind from the sitemap file?

Also which is better of the below:

  1. Access sitemap from web.config

  2. Access sitemap by giving the sitemap file name?

P.S: Newbie alert!

Upvotes: 2

Views: 1556

Answers (1)

abatishchev
abatishchev

Reputation: 100358

You can easily build a breadcrumbs:

Markup:

<asp:SiteMapPath runat="server" RenderCurrentNodeAsLink="True" SkipLinkText="" />

Web.config:

<siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
    <providers>
        <clear />
        <add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider, System.Web" siteMapFile="Web.sitemap" />
    </providers>
</siteMap>

Upvotes: 1

Related Questions