Class HierarchicalUrlRewriteProvider

The UrlRewriteProvider that handles rewriting of urls.

Inheritance
System.Object
HierarchicalUrlRewriteProvider
Namespace: EPiServer.Web
Assembly: EPiServer.dll
Version: 8.11.0
Syntax
public class HierarchicalUrlRewriteProvider : UrlRewriteProvider

Constructors

HierarchicalUrlRewriteProvider()

Initializes a new instance of the HierarchicalUrlRewriteProvider class.

Declaration
public HierarchicalUrlRewriteProvider()

HierarchicalUrlRewriteProvider(IContentRepository, PageTypeRepository, TemplateResolver, UrlResolver)

Initializes a new instance of the HierarchicalUrlRewriteProvider class.

Declaration
public HierarchicalUrlRewriteProvider(IContentRepository contentRepository, PageTypeRepository pageTypeRepository, TemplateResolver templateResolver, UrlResolver urlResolver)
Parameters
Type Name Description
IContentRepository contentRepository

The IContentRepository to use

PageTypeRepository pageTypeRepository

The PageTypeRepository to use.

TemplateResolver templateResolver

The template resolver.

UrlResolver urlResolver

The URL resolver.

Properties

IsIdKeep

Gets a value indicating whether this rewriter requires the use of the id query string parameter to pass through unchanged to and from the external format. Set this to true to indicate that a url rewritten to external actually uses id= and requires it to pass through any rewriting process unchanged.

Declaration
[Obsolete("The need for the ID keep functionality has been removed.")]
public override bool IsIdKeep { get; }
Property Value
Type Description
System.Boolean

false - Friendly URLs do not normally contain the id query string parameter

Overrides

UrlIdentifiers

Gets the list of URL identifiers.

Declaration
public IList<IHandleUrlForRewrite> UrlIdentifiers { get; }
Property Value
Type Description
System.Collections.Generic.IList<IHandleUrlForRewrite>

The URL identifiers.

Remarks

The URL identifiers are scanned sequentially until one is found that will handle the current URL.

Methods

ConvertToExternal(UrlBuilder, Object, Encoding)

Converts from internal, without regard to the context of internal/external URL.

Declaration
public override bool ConvertToExternal(UrlBuilder url, object internalObject, Encoding toEncoding)
Parameters
Type Name Description
UrlBuilder url

The URL.

System.Object internalObject

An optional internal representation of the URL, typically a PageReference

System.Text.Encoding toEncoding

The current encoding

Returns
Type Description
System.Boolean

true if any modifications were made

Overrides
Remarks

When converting to external, we may need to change the encoding used for escaped characters in the URL to conform to response encoding requirements which may differ from the internally stored format - which should always be UTF-8.

ConvertToExternalInternal(UrlBuilder, Object, Encoding)

Converts from internal EPiServer classic to the external 'friendly' URL representation. This is the only method that defines this mapping. It includes all globally valid rules for this transformation in the context of EPiServer, but not rules dependent on for example on the current running mode, i.e. view mode, edit mode etc or similar. The conversion must take language preferences into account when determining language.

Declaration
protected virtual bool ConvertToExternalInternal(UrlBuilder url, object internalObject, Encoding toEncoding)
Parameters
Type Name Description
UrlBuilder url

The URL.

System.Object internalObject

The internal representation of the object, if any. Typically it may be a PageReference.

System.Text.Encoding toEncoding

To encoding.

Returns
Type Description
System.Boolean

True if any changes done to the url, False otherwise.

Remarks

This is the only method that defines this mapping. It includes all globally valid rules for this transformation in the context of EPiServer, but not rules dependent on for example on the current running mode, i.e. view mode, edit mode etc or similar. The conversion must take language preferences into account when determining language.

ConvertToInternal(UrlBuilder, out Object)

Converts to internal, without regard to the context of internal/external URL.

Declaration
public override bool ConvertToInternal(UrlBuilder url, out object internalObject)
Parameters
Type Name Description
UrlBuilder url

The URL.

System.Object internalObject

An optional internal representation of the URL, typically a PageReference

Returns
Type Description
System.Boolean

true if any modifications were made

Overrides
Remarks

There is no support for changing encoding when converting to internal, since there is no requirement for this.

GetFriendlyPagePath(ContentReference, String)

Gets the friendly page path.

Declaration
protected virtual string GetFriendlyPagePath(ContentReference contentReference, string currentLanguageBranch)
Parameters
Type Name Description
ContentReference contentReference

The page reference.

System.String currentLanguageBranch

The current language branch.

Returns
Type Description
System.String

GetHtmlRewriter()

Gets an instance of a Html-rewriter to use when emitting HTML from EPiServer.

Declaration
public override HtmlRewriteToExternal GetHtmlRewriter()
Returns
Type Description
HtmlRewriteToExternal

A new instance of a HtmlRewriteToExternal-derived class

Overrides

Initialize(String, NameValueCollection)

Initializes the provider.

Declaration
public override void Initialize(string name, NameValueCollection config)
Parameters
Type Name Description
System.String name

The friendly name of the provider.

System.Collections.Specialized.NameValueCollection config

A collection of the name/value pairs representing the provider-specific attributes specified in the configuration for this provider.

Overrides
Exceptions
Type Condition
System.ArgumentNullException

The name of the provider is null.

System.InvalidOperationException

An attempt is made to call System.Configuration.Provider.ProviderBase.Initialize(System.String,System.Collections.Specialized.NameValueCollection) on a provider after the provider has already been initialized.

System.ArgumentException

The name of the provider has a length of zero.

TryConvertToInternal(UrlBuilder, out CultureInfo, out Object)

Converts to internal, without regard to the context of internal/external URL.

Declaration
public override bool TryConvertToInternal(UrlBuilder url, out CultureInfo preferredCulture, out object internalObject)
Parameters
Type Name Description
UrlBuilder url

The URL.

System.Globalization.CultureInfo preferredCulture

The preferred culture.

System.Object internalObject

An optional internal representation of the URL, typically a PageReference

Returns
Type Description
System.Boolean

true if any modifications were made

Overrides
Remarks

There is no support for changing encoding when converting to internal, since there is no requirement for this.

Extension Methods