Question

I have routing set up as follows:

void RegisterRoutes(RouteCollection routes)
{
    routes.MapPageRoute("", "Home", "~/Default.aspx");
    ......
}

I'm implementing breadcrumbs using a SiteMapPath control:

<asp:SiteMapPath ID="SiteMapPath1" CssClass="breadCrumbs" runat="server">
</asp:SiteMapPath>

Web.sitemap is set up as follows:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="Home" title="Home"  description="Home">    
        <siteMapNode url="~/About" title="About"  description="About">
            <siteMapNode url="~/History" title="History"  
                description="History" />    
        </siteMapNode>
    </siteMapNode>
</siteMap>

My problem is that when I navigate to mysite.com instead of mysite.com/default.aspx, the Home breadcrumb node does not appear. What am I missing?

UPDATE

I managed to get the "Home" node to display by updating Web.sitemap as follows:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="Home" title="Home"  description="Home">
        <siteMapNode url="~/Default.aspx" title=""  description="" />
        <siteMapNode url="~/About" title="About"  description="About">
            <siteMapNode url="~/History" title="History"  
                description="History" />
        </siteMapNode>
    </siteMapNode>
</siteMap>

The only remaining problem is that the path separator is still displaying on home page for mysite.com

Is there a way to programatically render the separator invisible for the home page? The SiteMapPath control itself is in a master page.

enter image description here

Was it helpful?

Solution

Maybe you should change your sitemap file as follows :

<?xml version="1.0" encoding="utf-8" ?>
<siteMap xmlns="http://schemas.microsoft.com/AspNet/SiteMap-File-1.0" >
    <siteMapNode url="~/" title="Global Site Name or Welcome Message"  description="Home">
        <siteMapNode url="~/Home" title="Home"  description="" />
        <siteMapNode url="~/About" title="About"  description="About">
            <siteMapNode url="~/History" title="History"  
                description="History" />
        </siteMapNode>
    </siteMapNode>
</siteMap>

and from the sitemapdatasource you should set ShowStartingNode="false" and I think that this solves both of your problems at once...

NOTE: of course this will require that you made this change in the global.asax file (VB):

RouteTable.Routes.MapPageRoute("Home0", "", "~/Default.aspx", True)
RouteTable.Routes.MapPageRoute("Home1", "Home", "~/Default.aspx", True)

hope this helps...

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top