Try our conversational search powered by Generative AI!

Class PageReference

Holds references to pages in the EPiServer system.

Inheritance
System.Object
PageReference
Implements
System.IComparable
System.IComparable<ContentReference>
System.IEquatable<ContentReference>
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 11.20.7
Syntax
public class PageReference : ContentReference, IComparable, IReadOnly<ContentReference>, IComparable<ContentReference>, IEquatable<ContentReference>, IReadOnly<PageReference>, IReadOnly
Remarks

Instead of using raw integer IDs, the ID is packaged in a PageReference structure. A page can have several versions and even be located on another physical server. This information is also stored inside the structure.

Constructors

PageReference()

Initializes a new instance of the PageReference class.

Declaration
public PageReference()

PageReference(ContentReference)

Initializes a new instance of the PageReference class from a ContentReference.

Declaration
public PageReference(ContentReference contentLink)
Parameters
Type Name Description
ContentReference contentLink

PageReference(Int32)

Initialize a new PageReference with page id.

Declaration
public PageReference(int pageID)
Parameters
Type Name Description
System.Int32 pageID

The Page ID to set

PageReference(Int32, Boolean)

Initialize a new PageReference with page id and any available version. If no version is published the most recently saved will be loaded.

Declaration
public PageReference(int pageID, bool anyVersion)
Parameters
Type Name Description
System.Int32 pageID

The page id to set

System.Boolean anyVersion

This parameter is not used, see remarks

PageReference(Int32, Int32)

Initialize a new PageReference with page id and working version.

Declaration
public PageReference(int pageID, int workPageID)
Parameters
Type Name Description
System.Int32 pageID

The page id to set

System.Int32 workPageID

The work id to set

PageReference(Int32, Int32, String)

Initialize a new PageReference with page id, working version and remote site.

Declaration
public PageReference(int pageID, int workPageID, string remoteSite)
Parameters
Type Name Description
System.Int32 pageID

The page id to set

System.Int32 workPageID

The version to set

System.String remoteSite

The name of the remote site

PageReference(Int32, Int32, String, Boolean)

Initialize a new PageReference with page id, working version and remote site.

Declaration
public PageReference(int pageID, int workPageID, string remoteSite, bool anyVersion)
Parameters
Type Name Description
System.Int32 pageID

The page id to set

System.Int32 workPageID

The version to set

System.String remoteSite

The name of the remote site

System.Boolean anyVersion

This parameter is not used, see remarks

PageReference(Int32, String)

Initialize a new PageReference with page id and remote site.

Declaration
public PageReference(int pageID, string remoteSite)
Parameters
Type Name Description
System.Int32 pageID

The page id to set

System.String remoteSite

The name of the remote site

PageReference(String)

Initialize a new PageReference from a string in the format pageID[_workID[_remoteSite]] or - throws EPiServerException on invalid argument

Declaration
public PageReference(string complexReference)
Parameters
Type Name Description
System.String complexReference

The string containing page information

Exceptions
Type Condition
EPiServerException

Thrown if the string cannot be parsed as a valid PageReference.

Fields

EmptyReference

Returns an empty PageReference.

Declaration
public static readonly PageReference EmptyReference
Field Value
Type Description
PageReference

SelfReference

Returns a PageReference that references the current page.

Declaration
public static readonly PageReference SelfReference
Field Value
Type Description
PageReference

Methods

Copy()

Copies this instance.

Declaration
public PageReference Copy()
Returns
Type Description
PageReference

CreateWritableClone()

Create a copy of the current object instance that is writable.

Declaration
public PageReference CreateWritableClone()
Returns
Type Description
PageReference

A new copy of the object.

Remarks

The cloning is a deep-copy.

IsNullOrEmpty(PageReference)

Determines whether the specified page link is null or empty.

Declaration
public static bool IsNullOrEmpty(PageReference pageLink)
Parameters
Type Name Description
PageReference pageLink

The page link.

Returns
Type Description
System.Boolean

true if pege link is null or empty; otherwise, false.

IsValue(PageReference)

Determines whether the passed PageReference is initiated with a value.

Declaration
public static bool IsValue(PageReference pageLink)
Parameters
Type Name Description
PageReference pageLink

The PageReference object to be checked.

Returns
Type Description
System.Boolean

true if the passed PageReference is not null and does not equal EmptyReference or SelfReference; otherwise, false.

Parse(String)

Parse and return a PageReference from a string.

Declaration
public static PageReference Parse(string s)
Parameters
Type Name Description
System.String s

The string, in the format pageID[_workID[_remoteSite]].

Returns
Type Description
PageReference

The PageReference, or PageReference.EmptyReference if it's invalid

Exceptions
Type Condition
EPiServerException

If string is not parsable as a pagereference

ParseUrl(String)

Parse a url for PageLink. It is assumed that the url is root-relative, i.e. starts with a "/".

Declaration
public static PageReference ParseUrl(string url)
Parameters
Type Name Description
System.String url

Url to parse, assumed to start with "/"

Returns
Type Description
PageReference

A PageReference or PageReference.EmptyReference if it's not a valid reference

Remarks

In order to successfully parse a FURL with ParserUrl, first convert the FURL to an internal url - use the UrlRewriteProvider.ConvertToInternal method.

TryParse(String, out PageReference)

Create a new PageReference from a string in the format pageID[_workID[_remoteSite]]

Declaration
public static bool TryParse(string complexReference, out PageReference result)
Parameters
Type Name Description
System.String complexReference

The string containing page information.

PageReference result

The PageReference created from the string.

Returns
Type Description
System.Boolean

True if parsing was successful.

Implements

System.IComparable
System.IComparable<T>
System.IEquatable<T>

Extension Methods