Class ContentRouteHelper
The ContentRouteHelper class provides information about the requrested content of the current web request.
Implements
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: 9.12.2Syntax
public class ContentRouteHelper : IContentRouteHelper
Constructors
ContentRouteHelper(RequestContext, RouteCollection, IViewContentRetriever, IContentLoader)
Initializes a new instance of the ContentRouteHelper class.
Declaration
public ContentRouteHelper(RequestContext context, RouteCollection routes, IViewContentRetriever viewContentRetriever, IContentLoader contentLoader)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.Routing.RequestContext | context | The context. |
| System.Web.Routing.RouteCollection | routes | The routes. |
| IViewContentRetriever | viewContentRetriever | The view content retriever. |
| IContentLoader | contentLoader | The content loader |
ContentRouteHelper(RequestContext, RouteCollection, ViewContentRetriever, IContentLoader)
Declaration
[Obsolete("Use alternative constructor")]
public ContentRouteHelper(RequestContext context, RouteCollection routes, ViewContentRetriever viewContentRetriever, IContentLoader contentLoader)
Parameters
| Type | Name | Description |
|---|---|---|
| System.Web.Routing.RequestContext | context | |
| System.Web.Routing.RouteCollection | routes | |
| ViewContentRetriever | viewContentRetriever | |
| IContentLoader | contentLoader |
Properties
Content
Gets the content.
Declaration
public virtual IContent Content { get; }
Property Value
| Type | Description |
|---|---|
| IContent |
ContentLink
Gets the content link.
Declaration
public virtual ContentReference ContentLink { get; }
Property Value
| Type | Description |
|---|---|
| ContentReference |
ContentLoader
Get the Content Loader
Declaration
protected IContentLoader ContentLoader { get; }
Property Value
| Type | Description |
|---|---|
| IContentLoader |
ContentRetriever
Gets the view content retriever.
Declaration
protected IViewContentRetriever ContentRetriever { get; }
Property Value
| Type | Description |
|---|---|
| IViewContentRetriever |
LanguageID
Gets the language string for the current page.
Declaration
public virtual string LanguageID { get; }
Property Value
| Type | Description |
|---|---|
| System.String |
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.
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();
}
}
}
RequestContext
Gets information about an HTTP request that matches the defined route.
Declaration
protected RequestContext RequestContext { get; }
Property Value
| Type | Description |
|---|---|
| System.Web.Routing.RequestContext |
ViewContentRetriever
Gets the view content retriever.
Declaration
[Obsolete("Use ContentRetriever instead")]
protected ViewContentRetriever ViewContentRetriever { get; }
Property Value
| Type | Description |
|---|---|
| ViewContentRetriever |
Methods
SetRouteDataIfPageNotRouted()
Sets the route data if page not routed yet.
Declaration
protected virtual void SetRouteDataIfPageNotRouted()