Question

I am using SiteMapPath to display the menu.

<?xml version="1.0" encoding="utf-8" ?>
<siteMapNode url="default.aspx" title="Home"  description="Sitemap example's home page">
  <siteMapNode url="products.aspx" title="Products"  description="Products listing page">
    <siteMapNode url="products/product1.aspx" title="Product 1"  description="" />
    <siteMapNode url="products/product2.aspx" title="Product 2"  description="" />        
  </siteMapNode>
  <siteMapNode url="services.aspx" title="Services"  description="Services listing page" >
    <siteMapNode url="services/service1.aspx" title="Services 1"  description="" />
    <siteMapNode url="services/service2.aspx" title="Services 2"  description="" />
  </siteMapNode>
</siteMapNode>

I want to link another website in my menu like

<siteMapNode url="http://www.google.com" title="Google"  description="" />  

but the Item is not displaying. Is it possible to link the website in sitemap?

Was it helpful?

Solution

I think that post may contain a solution of your problem: Referencing external URLs in your web.sitemap in ASP.NET

EDIT: As the site www.sciosoft.com is no longer responding, here's the blog text (written by James Fielding) copied from http://web.archive.org/web/20170821015820/http://www.sciosoft.com:80/blogs/post/2010/02/23/Referencing-external-URLs-in-your-websitemap-in-ASPNET.aspx.

In ASP.NET, we often use site maps to set up navigation, particularly for menus. By default, the ASP.NET site-map provider uses the "Web.sitemap" file. Here is an example of this file for a simple site:

<?xml version="1.0" encoding="utf-8" ?>
<siteMap>
    <siteMapNode title="Home" description="Home" url="~/default.aspx">
        <siteMapNode title="Services" description="Services we offer" url="~/Services.aspx">
            <siteMapNode title="Consulting" description="Consulting services" url="~/Consulting.aspx" />
            <siteMapNode title="Support" description="Supports plans" url="~/Support.aspx" />
        </siteMapNode>
        <siteMapNode title="About Us" description="About Us" url="~/AboutUs.aspx">
            <siteMapNode title="Company" description="Our people and offices" url="~/Company.aspx" />
            <siteMapNode title="Blogs" description="Blogs from us to you"
              url="http://blogs.mysite.com/default.aspx" />
        </siteMapNode>
    </siteMapNode>
</siteMap>

So our basic menu will look like this:

Home Services Consulting Support About Us Company Blogs

Notice that the "Blogs" node in the "About Us" section references an outside URL. This is not a problem, until you start adding role-base security to the site. Specifically, once you set you securityTrimmingEnabled="true" in the Web.config or the Web.sitemap file, the "Blogs" node disappears, and you're left scratching your head.

Home Services Consulting Support About Us Company

At this point, you'll find that some developers get rid of the web.sitemap, and start hard coding menu items. However, there is a really easy fix for this behaviour. Just allow everyone access to the Blogs node so that it doesn't get trimmed:

<siteMapNode title="Blogs" description="Blogs from us to you"
    url="http://blogs.mysite.com/default.aspx" roles="*">

By adding roles="*", we've got our blog back. That was almost too easy.

Just for completeness, I'm going to mention that we could have also just disabled the security trimming in the Web.sitemap file by adding securityTrimmingEnabled="false" to the Blogs node. Although I'm not a big fan of this method, as I find it makes the Web.sitemap less clear on what we're trying to accomplish, which is never good for the next guy working on the site, but the choice is yours.

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