I am upgrading a site from EpiServer 7 to 7.5 and got an error as below:
‘Project.Models.Pages.ArticlePage' does not contain a definition for 'ExternalLinkUrl' and no extension method 'ExternalLinkUrl' accepting a first argument of type ‘Project.Models.Pages.ArticlePage' could be found (are you missing a using directive or an assembly reference?)
Infact after some investigation I found that the class LinkExtensions in which this method is present itself is not there.
Anyone has any idea what is the good replacement for this?
Take a look at this blogpost (make sure to read comments section as well).
There is a Geta.EPi.Extensions library which has extension method for it: GetFriendlyUrl()
It also has multipe other usefult extension methods for EPiServer development.
GitHub repository for it: https://github.com/Geta/EPi.Extensions
EPiServer NuGet feed: http://nuget.episerver.com/en/OtherPages/Package/?packageId=Geta.EPi.Extensions
Thanks Marija, I tried the solution given by you and now there is no more compilation error.
But I am not able to run the application and verify what it returns as I have one more issue in the migrated code.
Thanks again for your help.
The solution given in the blog post is not complete though. Not if you have multiple hosts or websited configured in your Episerver instance. There is another parameter you can use in the UrlResolver, ForceCanonical, unfortuantely it doen't give you an external URL but it solves some issues.
We use this code:
public ExternalUrlResolver(ContentReference contentLink, CultureInfo contentLanguage, bool absoluteUrl, string languageBranch)
var result = ServiceLocator.Current.GetInstance<UrlResolver>().GetUrl(
ContextMode = ContextMode.Default,
ForceCanonical = absoluteUrl
// HACK: Temprorary fix until GetUrl and ForceCanonical works as expected,
// i.e returning an absolute URL even if there is a HTTP context that matches the page's
// site definition and host.
if (Uri.TryCreate(result, UriKind.RelativeOrAbsolute, out relativeUri))
var siteDefinitionResolver = ServiceLocator.Current.GetInstance<SiteDefinitionResolver>();
var siteDefinition = siteDefinitionResolver.GetDefinitionForContent(contentLink, true, true);
var hosts = siteDefinition.GetHosts(contentLanguage, true).ToList();
var host = hosts.FirstOrDefault(h => h.Type == HostDefinitionType.Primary)
?? hosts.FirstOrDefault(h => h.Type == HostDefinitionType.Undefined);
var basetUri = siteDefinition.SiteUrl;
if (host != null && host.Name.Equals("*") == false)
// Try to create a new base URI from the host with the site's URI scheme. Name should be a valid
// authority, i.e. have a port number if it differs from the URI scheme's default port number.
Uri.TryCreate(siteDefinition.SiteUrl.Scheme + "://" + host.Name, UriKind.Absolute, out basetUri);
var absoluteUri = new Uri(basetUri, relativeUri);
this.ExternalUrl = absoluteUri.AbsoluteUri;
this.ExternalUrl = result;
I just blogged about this topic, http://dodavinkeln.se/post/how-to-get-the-external-url-to-content