views:

1356

answers:

5

I have a certain page (we'll call it MyPage) that can be accessed from three different pages. In the Web.sitemap file, I tried to stuff the XML for this page under the three separate nodes like this:

< Page 1 >
  < MyPage / >
  ...
< /Page 1 >

< Page 2 >
  < MyPage / >
  ...
< /Page 2 >

< Page 3 >
  < MyPage / >
  ...
< /Page 3 >

In doing so I received the following error:

Multiple nodes with the same URL 'Default.aspx' were found. XmlSiteMapProvider requires that sitemap nodes have unique URLs.

I read online that the SiteMapNodes are stored as a dictionary internally which explains why I can't use the same URL. In any case, I'm just looking for alternate ways to go about solving this problem. Any suggestions would be greatly appreciated.

+2  A: 

That's not really the intended purpose of the Web.sitemap file.

From MSDN Docs of the SiteMap class,

Fundamentally, the SiteMap is a container for a hierarchical collection of SiteMapNode objects. However, the SiteMap does not maintain the relationships between the nodes; rather, it delegates this to the site map providers.

So, to paraphrase, the web.SiteMap only describes the hierarchy of the pages, and not the relationships between those pages.

However, if your intention is just to have the 'MyPage" linked from your other pages, then you don't need to have MyPage as child nodes of those other pages anyway.

Hope that helps clarify things a little.

Scott Ferguson
I need the page to include the sitemap because I'm saving context from each of the three previous pages. That way the user can click the previous page in the sitemap, and it will load the data I stored (i.e. load the data from their previous search).
YourMomzThaBomb
A: 

I know you can have two different entries of ~/folder/index.aspx and ~/folder/ both point to the same place. A bit of a hack, yes, but maybe there's a way you can take this further?

  • ~/folder/index.aspx
  • ~/folder/
  • ~/folder
Matt Hanson
A: 

You could try this...

<siteMapNode url="ListAll.aspx">
  <siteMapNode url ="Detail.aspx?node=all" />
</siteMapNode>
<siteMapNode url="ListMine.aspx">
  <siteMapNode url ="Detail.aspx?node=mine" />
</siteMapNode>

But it breaks if you try to go to "Detail.aspx?node=all&id=13" (Which I'm still trying solve.)

Beaker
A: 

One simple but effective way is to differentiate by using a different query string:

  • default.aspx?page=1
  • default.aspx?page=2
  • default.aspx?page=3

They're all different in a sitemap, though they all point to the same page.

Atømix
A: 

How do you get round this issue if for example you have the following paths through pages (for example)?

StartPage -> Page2 -> Page3 -> Page4 -> EndPage

StartPage -> Page3 -> Page4 -> EndPage

StartPage -> Page4 -> EndPage

You couldn't use url parameters in this case as all paths end at EndPage (well you could, but it would get really messy, very quickly). If someone jumps in to Page4 for example at the start of a session there wouldn't be any path 'context' anyway, but apart from that problem, any ideas?

Sprintstar