SaaS CMS has officially launched! Learn more now.

Class PageRouteHelper

The PageRouteHelper class is used to provide access to information about the requested CMS page of the current web request.

Inheritance
System.Object
PageRouteHelper
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.Routing
Assembly: EPiServer.dll
Version: 7.19.2
Syntax
public class PageRouteHelper : ContentRouteHelper
Remarks

The class is supported in both Web Forms and MVC.

PageRouteHelper is registred by the ServiceLocator in the InitializationModule, which makes it possible to create an instance of the class by the method GetInstance<TService>().

PageRouteHelper is used by PageBase to get the CurrentPageLink for a page.

MVC controls can inherit EPiServer.Web.Mvc.PageController{T} to get the property EPiServer.Web.Mvc.PageController{T}.PageContext, which is an instance of this class.

This class is thread safe.

Examples

The following code example demonstrates how to get information about the requested CMS page for the current web request

Constructors

PageRouteHelper(RequestContext, RouteCollection, ViewContentRetriever, IContentLoader)

Initializes a new instance of the PageRouteHelper class.

Declaration
public PageRouteHelper(RequestContext context, RouteCollection routes, ViewContentRetriever viewContentRetriever, IContentLoader contentLoader)
Parameters
Type Name Description
System.Web.Routing.RequestContext context

The context, which encapsulates information about an HTTP request that matches the defined route.

System.Web.Routing.RouteCollection routes

If the page hasn't been routed, the routing system will be called with the supplied routing collection to receive nessasary information about the current page.

ViewContentRetriever viewContentRetriever

The view content retriever.

IContentLoader contentLoader

The content loader

Remarks

The public properties in the class gets initialized for execution. Each value will be set the first time it gets called, and cached for the current instance.

PageRouteHelper is registred by the ServiceLocator in the InitializationModule, which makes it possible to create an instance of the class by the method GetInstance<TService>().

If the page hasn't been routed, the routing system will be called with the supplied routes to receive necessary information about the current page

Examples

The following code example demonstrates how to get information about the requested CMS page for the current web request

Properties

Page

Gets the current page.

Declaration
public virtual 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.

Examples

The following code example demonstrates how to get information about the requested CMS page for the current web request.

Gets the page link for the current page.

Declaration
public virtual 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.

Extension Methods

See Also