Try our conversational search powered by Generative AI!

Why is PermanentLinkMapStore.ToMapped returning false?


I'm trying to use 'ToPageDataCollection()' to get a list of links and add this to my repeater.
The problem is that the function 'PermanentLinkMapStore.ToMapped(url)' inside 'ToPageDataCollection' returns false.

More exactly this is not working:

var url = new UrlBuilder(linkItem.Href); // url is now {}
PermanentLinkMapStore.ToMapped(url); // This returns false. Why?

This is the code I use to get link list and use it as a datasource for my repeater:

var relatedLinkItems = CurrentPage["shortcutList"] as LinkItemCollection;
var relatedLinkPages = relatedLinkItems.ToPageDataCollection();
relatedLinkPages = FilterForVisitor.Filter(relatedLinkPages);

var pages = FilterForVisitor.Filter(relatedLinkPages);
rptshortcutList.DataSource = pages;


Aug 18, 2011 11:10

Could you post the code for ToPageDataCollection()?

Aug 18, 2011 12:10

I thought that function was default EPiServer. Here it is:


    public static class LinkItemCollectionUtility
        public static PageDataCollection ToPageDataCollection(this LinkItemCollection linkItemCollection)
            var pageDataCollection = new PageDataCollection();
            foreach (var linkItem in linkItemCollection)
                var url = new UrlBuilder(linkItem.Href);
                if (PermanentLinkMapStore.ToMapped(url))
                    var page = DataFactory.Instance.GetPage(PermanentLinkUtility.GetPageReference(url));
                    if (page != null)
            return pageDataCollection;


Aug 18, 2011 12:18

The code looks fine. Only way it should return false is for external links, e-mail address, documents etc. Are you sure this is an internal link?

Aug 18, 2011 12:25

I'm debugging in Visual Studio and the URL is a object, where 'uri' is the above url.

Aug 18, 2011 12:45

Yes, but since it is returning false EPiServer cannot find it in its database. Try readding the pages in the LinkItemCollection property in edit mode and see if that makes a difference.

Aug 18, 2011 12:53

PermanentLinkMapStore is used to convert between the permanent link format (e.g. ~/link<guid>.aspx) to the "classic" format (e.g. /templates/pages/page.aspx?id=7).

In your example the url is in the FURL format, to get the page from that format you could instead of PermanentLinkMapStore use Global.UrlRewriteProvider.TryConvertToInternal. The second out parameter will in case of a match typically be the PageReference to the page.

Aug 18, 2011 13:06
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.