Class PermanentLinkUtility

Utility functions for the permanent link functionality

Inheritance
System.Object
PermanentLinkUtility
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Web
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
public static class PermanentLinkUtility

Methods

ChangeGuid(String, Guid)

Changes the Guid in a permanent link Url

Declaration
public static string ChangeGuid(string url, Guid guid)
Parameters
Type Name Description
System.String url

The URL.

System.Guid guid

The GUID.

Returns
Type Description
System.String

FindContentReference(Guid)

Tries to find a content reference given a Guid.

Declaration
public static ContentReference FindContentReference(Guid guid)
Parameters
Type Name Description
System.Guid guid

The GUID.

Returns
Type Description
ContentReference

FindContentReference(Guid, IPermanentLinkMapper)

Tries to find a content reference given a Guid.

Declaration
public static ContentReference FindContentReference(Guid guid, IPermanentLinkMapper permanentLinkMapper)
Parameters
Type Name Description
System.Guid guid

The GUID.

IPermanentLinkMapper permanentLinkMapper

The permanent link mapper.

Returns
Type Description
ContentReference

Reference to content, or null if not found

FindGuid(PageReference)

Tries to find a GUID given a page reference

Declaration
public static Guid FindGuid(PageReference pageReference)
Parameters
Type Name Description
PageReference pageReference

The page reference.

Returns
Type Description
System.Guid

A valid link map, or null if not found

FindGuid(PageReference, IPermanentLinkMapper)

Tries to find a GUID given a page reference

Declaration
public static Guid FindGuid(PageReference pageReference, IPermanentLinkMapper permanentLinkMapper)
Parameters
Type Name Description
PageReference pageReference

The page reference.

IPermanentLinkMapper permanentLinkMapper

The permanent link mapper.

Returns
Type Description
System.Guid

A valid link map, or null if not found

FindPageReference(Guid)

Tries to find a page reference given a Guid.

Declaration
[Obsolete("Use FindContentReference instead")]
public static PageReference FindPageReference(Guid guid)
Parameters
Type Name Description
System.Guid guid

The GUID.

Returns
Type Description
PageReference

A valid link map, or null if not found

FindPageReference(Guid, IPermanentLinkMapper)

Tries to find a page reference given a Guid.

Declaration
[Obsolete("Use FindContentReference instead")]
public static PageReference FindPageReference(Guid guid, IPermanentLinkMapper permanentLinkMapper)
Parameters
Type Name Description
System.Guid guid

The GUID.

IPermanentLinkMapper permanentLinkMapper

The permanent link mapper.

Returns
Type Description
PageReference

A valid link map, or null if not found

GetContent(String)

Gets the content from the given href value.

Declaration
public static IContent GetContent(string hrefValue)
Parameters
Type Name Description
System.String hrefValue

The href value.

Returns
Type Description
IContent

GetContentReference(UrlBuilder)

Gets the content reference for the mappedUrl.

Declaration
public static ContentReference GetContentReference(UrlBuilder mappedUrl)
Parameters
Type Name Description
UrlBuilder mappedUrl

The mapped URL.

Returns
Type Description
ContentReference

ContentReference for the content. ContentReference.EmptyReference if it was not mapped to a content

GetGuid(Url)

Gets the GUID part from a permanent link

Declaration
public static Guid GetGuid(Url url)
Parameters
Type Name Description
Url url

The URL.

Returns
Type Description
System.Guid

The Guid from the link or Guid.Empty if it was no proper permanent link

GetGuid(Url, out String)

Gets the GUID part from a permanent link

Declaration
public static Guid GetGuid(Url url, out string extension)
Parameters
Type Name Description
Url url

The URL.

System.String extension

The extension.

Returns
Type Description
System.Guid

The Guid from the link or Guid.Empty if it was no proper permanent link

GetGuid(UrlBuilder, out String)

Gets the GUID from a permanent link.

Declaration
public static Guid GetGuid(UrlBuilder url, out string extension)
Parameters
Type Name Description
UrlBuilder url

The permanent link, must be an absolute Uri, a root-relative Uri or an app-relative Uri

System.String extension

The extension from the permanent link

Returns
Type Description
System.Guid
Remarks

The only method to produce a corrent permanent link is via the method GetPermanentLinkUrl()

GetGuid(String)

Gets the GUID from an permanent link that may be expressed as virtualPath, a root-relative Url, an app-relative Url or as an absolulte Url.

Declaration
public static Guid GetGuid(string virtualPathOrUrl)
Parameters
Type Name Description
System.String virtualPathOrUrl

The virtual path or URL.

Returns
Type Description
System.Guid

GetGuid(String, out String)

Gets the GUID part from a permanent link

Declaration
public static Guid GetGuid(string virtualPathOrUrl, out string extension)
Parameters
Type Name Description
System.String virtualPathOrUrl

The virtual path or URL.

System.String extension

The extension.

Returns
Type Description
System.Guid

The Guid from the link or Guid.Empty if it was no proper permanent link

GetPageReference(UrlBuilder)

Gets the page reference for the mappedUrl.

Declaration
[Obsolete("Use GetContentReference instead")]
public static PageReference GetPageReference(UrlBuilder mappedUrl)
Parameters
Type Name Description
UrlBuilder mappedUrl

The mapped URL.

Returns
Type Description
PageReference

PageReference for the page. PageReference.EmptyReference if it was not mapped to a page

GetPermanentLinkUrl(Guid, String)

Gets a permanent link URL representation by building it. No lookup is performed.

Declaration
public static Uri GetPermanentLinkUrl(Guid guid, string extension)
Parameters
Type Name Description
System.Guid guid

The GUID.

System.String extension

The extension.

Returns
Type Description
System.Uri

The permanent link Url representing this Guid and extension

Remarks

The instances returned should be treated as opaque units. Do not parse or interpret the contents.

GetPermanentLinkVirtualPath(Guid, String)

Gets a permanent link virtual path representation by building it. No lookup is performed.

Declaration
public static string GetPermanentLinkVirtualPath(Guid guid, string extension)
Parameters
Type Name Description
System.Guid guid

The GUID.

System.String extension

The extension.

Returns
Type Description
System.String

The permanent link virtual path representing this Guid and extension

Remarks

The instances returned should be treated as opaque units. Do not parse or interpret the contents.

IsMappableUrl(UrlBuilder)

Determines whether the specified URL is a mappable URL.

Declaration
public static bool IsMappableUrl(UrlBuilder url)
Parameters
Type Name Description
UrlBuilder url

The URL.

Returns
Type Description
System.Boolean

true if the specified URL is a mappable URL; otherwise, false.

Remarks

The concept "mappable URL" is a URL that directly references an ASPX-page and is part of the local site.

TryParseGuid(String, out Guid)

Tries to get the get Guid from a string.

Declaration
[Obsolete("Use System.Guid.TryParse instead.")]
public static bool TryParseGuid(string g, out Guid guid)
Parameters
Type Name Description
System.String g

The Guid string.

System.Guid guid

The Guid, or Guid.Empty if it was not possible to get a Guid.

Returns
Type Description
System.Boolean

true if a valid guid was detected.