external links using a sitemap, 2.0

  • Thread starter Thread starter fernandezr
  • Start date Start date
F

fernandezr

I've successfully created a dynamic menu pulling data from a database
however all links thus far have all been virtual urls such as
/ABCD/default.aspx, /ABCD/profile.aspx, etc. Now I want to add urls
that are external to my site such as
http://www.rathergood.com/moon_song/ or http://www.cnn.com but when I
try to use these I get
"Exception Details: System.Web.HttpException:
'http://www.rathergood.com/moon_song/' is not a valid virtual path.".

It is failing on the AddNode method of StaticSiteMapProvider. I've
even tried
/ABCD/externalURL.aspx?url=http://www.rathergood.com/moon_song/ and
still get the same error.

Is there a way for me to reference an external url without having to
hardcode it into my page?

Thanks,
Happy Wednesday,
Robert
 
I am having the same problem. I am using the SqlSiteMapProvider class found
in the Feb 2006 MSDN Magazine. If I use the out-of-the-box
XmlSiteMapProvider, I can use an external URL just fine. Looks like both
providers derive from StaticSiteMapProvider, and SqlSiteMapProvider doesn't
override the AddNode method. There must be a reason...
 
We converted the C# file over to VB for our needs, but we did figure out a way around the virtual path problem.

' Build a tree of SiteMapNodes underneath the root node
While (reader.Read())
' Create another site map node and add it to the site map
Dim node As SiteMapNode = CreateSiteMapNodeFromDataReader(reader)

Try
AddNode(node, GetParentNodeFromDataReader(reader))
Catch excep As HttpException
node.Url = ""
AddNode(node, GetParentNodeFromDataReader(reader))
node.Url = reader.GetString(_indexUrl).Trim()
End Try

End While

You can only set the node.url to blank otherwise it throws the "Not a unique URL" error but this fixes the problem with virtual path.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top