Interface IContentRouteHelper
Provides information about the routed content of the current web request.
Namespace: EPiServer.Web.Routing
Assembly: EPiServer.dll
Version: 10.10.4Syntax
public interface IContentRouteHelper
Properties
Content
Gets the current routed IContent instance.
Declaration
IContent Content { get; }
Property Value
Type | Description |
---|---|
IContent |
ContentLink
Gets the reference to the current routed IContent instance.
Declaration
ContentReference ContentLink { get; }
Property Value
Type | Description |
---|---|
ContentReference |
LanguageID
Gets the language string for the current routed content.
Declaration
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();
}
}
}