Interface IPageRouteHelper

Provides information about the routed page and content of the current web request.

Namespace: EPiServer.Web.Routing
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
public interface IPageRouteHelper : IContentRouteHelper

Properties

Page

Gets the current routed page.

Declaration
PageData Page { get; }
Property Value
Type Description
PageData
Remarks

The property will be set the first time it gets called, and cached for the current instance.

When a request is partial routed to another content instance, the partial routed instance can be retreived from Content

Examples
  The following code example demonstrates how to get information about the requested CMS page for the current web request.
using System.Text;
using EPiServer.Web.Routing;
using EPiServer.ServiceLocation;

namespace CodeSamples.Routing
{
/// <summary>
/// Code sample class containing cref examples on how PageRouteHelper can be used.
/// </summary>
public class PageRouteInformation
{
/// <summary>
/// Gets information about the requested CMS page for the current web request
/// </summary>
public string GetPageRouteInformation()
{
var routeHelper = ServiceLocator.Current.GetInstance<IPageRouteHelper>();

StringBuilder routePageStringBuilder = new StringBuilder();

// Gets the display name
routePageStringBuilder.AppendFormat("Page name: {0}. ", routeHelper.Page.PageName);

// Gets the page id
routePageStringBuilder.AppendFormat("Page link id: {0}. ", routeHelper.PageLink.ID);

// Gets the version
routePageStringBuilder.AppendFormat("Page version: {0}. ", routeHelper.PageLink.WorkID);

// Gets the language
routePageStringBuilder.AppendFormat("Language: {0}. ", routeHelper.LanguageID);


return routePageStringBuilder.ToString();
}
}
}

Gets the page link for the current routed page.

Declaration
PageReference PageLink { get; }
Property Value
Type Description
PageReference

Webform pages, inheriting from PageBase, can use the property CurrentPageLink instead of this class, to receive the PageReference of the current web request.

  The following code example demonstrates how to get information about the requested CMS page for the current web request.
using System.Text;
using EPiServer.Web.Routing;
using EPiServer.ServiceLocation;

namespace CodeSamples.Routing
{
/// <summary>
/// Code sample class containing cref examples on how PageRouteHelper can be used.
/// </summary>
public class PageRouteInformation
{
/// <summary>
/// Gets information about the requested CMS page for the current web request
/// </summary>
public string GetPageRouteInformation()
{
var routeHelper = ServiceLocator.Current.GetInstance<IPageRouteHelper>();

StringBuilder routePageStringBuilder = new StringBuilder();

// Gets the display name
routePageStringBuilder.AppendFormat("Page name: {0}. ", routeHelper.Page.PageName);

// Gets the page id
routePageStringBuilder.AppendFormat("Page link id: {0}. ", routeHelper.PageLink.ID);

// Gets the version
routePageStringBuilder.AppendFormat("Page version: {0}. ", routeHelper.PageLink.WorkID);

// Gets the language
routePageStringBuilder.AppendFormat("Language: {0}. ", routeHelper.LanguageID);


return routePageStringBuilder.ToString();
}
}
}

Extension Methods