PermanentLinkMapStore.TryToMapped and PermanentLinkUtility.GetContentReference not working after EPiServer 9 Upgrade

Dan
Dan
Vote:
 

we have used

string linkUrl;
if(PermanentLinkMapStore.TryToMapped(url, out linkUrl)){
....
}

and

var contRef = PermanentLinkUtility.GetContentReference(url);

But those are now not supported in EPiServer 9. So What should I do to correct this ?
Can I use "PermanentLinkMapStore.ToPermanent" as alternative to "PermanentLinkMapStore.TryToMapped" ?

#140729
Oct 28, 2015 16:13
Vote:
 

What about UrlResolver?

#140740
Oct 28, 2015 22:38
Vote:
 

As Valdis said. But I wanted to add that mapped URLs doesn't exist anymore, so your first code snippet doesn't make sense to handle in EPiServer 9 at all.

#140741
Oct 28, 2015 23:55
Dan
Vote:
 

Yes Valdis, I figured it out that I can get ContentReference like:

var content = UrlResolver.Current.Route(new UrlBuilder(url));
if (content?.ContentLink != null)
{
var contRef = content.ContentLink;
}


But the problem is what would be the alternative for "PermanentLinkMapStore.ToPermanent" ?

As per Johan, it is true that "PermanentLinkMapStore.ToPermanent" has no sense in EPiServer 9, but what would be the safest way to replace existing code ?

#140751
Oct 29, 2015 10:21
Vote:
 

Permanent links still exist. Mapped URL doesn't, which your first code snippet was referring to. So what are you trying to achieve, to mapped or to permanent?

You can try:

EPiServer.Web.Routing.UrlResolver.Current.GetPermanent();

or

EPiServer.Web.Routing.UrlResolver.Current.TryToPermanent();

to get a permanent link

#140752
Oct 29, 2015 10:37
Dan
Vote:
 

Sorry Johan, what I referring was "PermanentLinkMapStore.TryToMapped" has no sense in EPiServer 9. 

OK. So I'll try with "PermanentLinkMapStore.TryToPermanent".  Actually my intention is to get Permanent Link here

#140757
Oct 29, 2015 11:22
* 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.