Class PageReference
Holds references to pages in the EPiServer system.
Implements
Inherited Members
Namespace: EPiServer.Core
Assembly: EPiServer.dll
Version: 9.12.2Syntax
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(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 |
Properties
RemoteSite
A string that identifies a remote site as defined in the list of remote sites for this installation.
Declaration
[Obsolete("Use ProviderName property instead")]
public string RemoteSite { get; set; }
Property Value
Type | Description |
---|---|
System.String | True if it is a remote reference. |
Remarks
To see if the PageReference is a remote link, use the IsRemote() method rather than looking at the RemoteSite.
Exceptions
Type | Condition |
---|---|
System.NotSupportedException | Thrown if the instance is read-only. |
Methods
Copy()
Copies this instance.
Declaration
public PageReference Copy()
Returns
Type | Description |
---|---|
PageReference |
CreateReferenceToPublishedPage()
Creates a new reference to the published version of page. That is with same ID and ProviderName but without WorkID.
Declaration
[Obsolete("This method has performance implications since it always clones objects, use ToReferenceWithoutVersion extension method instead")]
public PageReference CreateReferenceToPublishedPage()
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.
IsAnyVersion()
Indicates if the PageReference references a specific version or may be used to load any available version.
Declaration
[Obsolete("Use property GetPublishedOrLatest instead")]
public bool IsAnyVersion()
Returns
Type | Description |
---|---|
System.Boolean |
|
Remarks
This method only returns true
if the PageReference object was created via the PageReference(Int32, Boolean)
constructor. Typically, that constructor is used when you want to load the latest version a page regardless if it's
published or not.
When a PageReference with GetAnyVersion is set to true
is passed to GetPage(PageReference)
the returned PageData object will be, in order of preference:
If AnyVersion is set to true
, any value assigned to WorkID will be ignored.
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 |
|
IsRemote()
Check if this reference is a remote reference.
Declaration
[Obsolete("Use property IsExternalProvider instead")]
public bool IsRemote()
Returns
Type | Description |
---|---|
System.Boolean | True if it is a remote reference. |
Remarks
A PageReference can point to an external site as indicated by the RemoteSite property.
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 |
|
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. |