Cipher
Cipher

Reputation: 6082

SiteMapPath not appearing

I have added a Web.sitemap and added the siteMapNode's to it. In addition, I have placed the asp:SiteMapPath control on the web page but on running nothing is displayed.

Here's the code of the my SiteMapPath control:

<asp:SiteMapPath ID="SiteMapPath1" runat="server" Font-Names="Verdana" Font-Size="0.8em">
    <CurrentNodeStyle ForeColor="#333333" />
    <NodeStyle Font-Bold="True" ForeColor="#666666" />
    <PathSeparatorStyle Font-Bold="True" ForeColor="#1C5E55" />
    <RootNodeStyle Font-Bold="True" ForeColor="#1C5E55" />
</asp:SiteMapPath>

Doesn't SiteMapPath control pickup Web.sitemap automatically? or anything else if left? In case, Web.sitemap is to checked, here it is.

Upvotes: 3

Views: 4620

Answers (2)

vvasch
vvasch

Reputation: 366

I also encountered this problem. Writing a very simple Website.

The problem was that pages that are not in the Web.sitemap are not included in the breadcrumbs. See first note on http://msdn.microsoft.com/en-us/library/ms178418(v=vs.100).aspx. I had listed all pages in Web.sitemap, but with the .aspx extension. For example:

<siteMapNode url="~/Contact.aspx" title="Contact"  description="Contact information" />

When I visited the page in a browser, the URL got "cleaned" to http://localhost/Contact. Meaning, without the .aspx extension. I don't know which module is responsible for this. When I changed the entry in Web.sitemap by removing .aspx, the breadcrumbs were showing up on the page. So, the line looks like:

<siteMapNode url="~/Contact" title="Contact"  description="Contact information" />

edit: The package responsible for the URL rewriting is the FriendlyUrls Package (http://www.nuget.org/packages/Microsoft.AspNet.FriendlyUrls)

Upvotes: 6

abatishchev
abatishchev

Reputation: 100248

Have you configured XML SiteMap provider into your Web.config?

<?xml version="1.0" encoding="utf-8"?>
<configuration>
    <system.web>
        <siteMap defaultProvider="XmlSiteMapProvider" enabled="true">
            <providers>
                <clear />
                <add name="XmlSiteMapProvider" type="System.Web.XmlSiteMapProvider, System.Web, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" siteMapFile="Web.sitemap" />
            </providers>
        </siteMap>
    </system.web>
</configuration>

Also setup the control:

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

Upvotes: 3

Related Questions