LinkCollection links are wrong

Vote:
 

Has anyone ever seen the individual items in the LinkCollection get output with links like this:

~/link/61d584ca62db46c9a90b61afc6d1cbf0.aspx

I can't see how I'm doing anything oddly, but whenever I link to a page within EPiServer within a LinkCollection, that's the link that comes out.  I've debugged and gone all the back to just before I DataBind, and, indeed, this is the Href of the LinkItem objects in the LinkItemCollection.

Anyone seen this before?

#37678
Mar 16, 2010 14:16
Vote:
 

You can't use the linkItem.href directly on internal links because it's in the internal permanentlink format.

If you want a link from each link item ute linkitem.ToMappedLink() or

Use PermanentLinkMapStore.TryToMapped if you want to create you're own links.

/Per

 

#37685
Mar 16, 2010 15:10
Vote:
 

The following blog post should guide you on your way:
http://marekblotny.blogspot.com/2009/02/episerver-5-r2-and-link-collection.html

#37686
Mar 16, 2010 15:11
Vote:
 

Yes - this is how EPiServer stores each link item in the database (as part of the PermanentLinkMapStore), if you inspect the LinkItem object you'll see that there ia a method called

.ToMappedLink() which will give you the mapped friendly url which I imagine is what you wish to render to the page.

You may also find this blog post handy Convert a LinkItemCollection to a list of PageData

#37688
Edited, Mar 16, 2010 15:27
Vote:
 

Thanks, everyone.  I appreciate the help.

#37698
Mar 17, 2010 6:10
Vote:
 

What I was looking for was the GetMappedHref() method.  This returns the correct link.

 

<a href="<%# ((EPiServer.SpecializedProperties.LinkItem)Container.DataItem).GetMappedHref() %> %>"><%# Eval("Text") %></a>

#37726
Mar 17, 2010 15:04
Vote:
 

I'm having this problem in the edit mode on a CMS 5 site, after updating some pages programmatically. A few of the pages updated got their linkURL messed up, and displays links like the above. What causes this?

These pages have ~link/[guid].aspx style links in the edit tree as well as in page lists on the site.

BR

Jakob

#45812
Nov 18, 2010 9:27