Class HierarchicalUrlHandler
An implementation of a URL handler that supports hierarchical URL:s (a k a Friendly URL:s)
Implements
Inherited Members
Namespace: EPiServer.Web
Assembly: EPiServer.dll
Version: 8.11.0Syntax
public class HierarchicalUrlHandler : CachedUrlHandler, IHandleUrlForRewrite
Constructors
HierarchicalUrlHandler(UrlBuilder, ContentReference)
Initializes a new instance of the HierarchicalUrlHandler class.
Declaration
public HierarchicalUrlHandler(UrlBuilder url, ContentReference cachedInternalObject)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | url | The URL. |
ContentReference | cachedInternalObject | The cached internal object. |
HierarchicalUrlHandler(UrlBuilder, ContentReference, IContentRepository, PageTypeRepository, TemplateResolver)
Initializes a new instance of the HierarchicalUrlHandler class.
Declaration
public HierarchicalUrlHandler(UrlBuilder url, ContentReference cachedInternalObject, IContentRepository contentRepository, PageTypeRepository pageTypeRepository, TemplateResolver templateResolver)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | url | The URL. |
ContentReference | cachedInternalObject | The cached internal object. |
IContentRepository | contentRepository | The IContentRepository that should be used by this instance. |
PageTypeRepository | pageTypeRepository | The PageTypeRepository that should be used by this instance. |
TemplateResolver | templateResolver | The control resolver. |
HierarchicalUrlHandler(String)
Initializes a new instance of the HierarchicalUrlHandler class.
Declaration
public HierarchicalUrlHandler(string friendlyUrlExtension)
Parameters
Type | Name | Description |
---|---|---|
System.String | friendlyUrlExtension | The friendly URL extension. |
HierarchicalUrlHandler(String, IContentRepository, PageTypeRepository, TemplateResolver)
Initializes a new instance of the HierarchicalUrlHandler class.
Declaration
public HierarchicalUrlHandler(string friendlyUrlExtension, IContentRepository contentRepository, PageTypeRepository pageTypeRepository, TemplateResolver templateResolver)
Parameters
Type | Name | Description |
---|---|---|
System.String | friendlyUrlExtension | The friendly URL extension. |
IContentRepository | contentRepository | The IContentRepository that should be used by this instance. |
PageTypeRepository | pageTypeRepository | The PageTypeRepository that should be used by this instance. |
TemplateResolver | templateResolver | The control resolver. |
HierarchicalUrlHandler(Uri, ContentReference)
Initializes a new instance of the HierarchicalUrlHandler class for handling cached requests
Declaration
public HierarchicalUrlHandler(Uri cachedUri, ContentReference cachedInternalObject)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | cachedUri | The resolved URL |
ContentReference | cachedInternalObject | The data returned in internalObject, which is a page reference in this case. |
HierarchicalUrlHandler(Uri, ContentReference, IContentRepository, PageTypeRepository, TemplateResolver)
Initializes a new instance of the HierarchicalUrlHandler class for handling cached requests
Declaration
public HierarchicalUrlHandler(Uri cachedUri, ContentReference cachedInternalObject, IContentRepository contentRepository, PageTypeRepository pageTypeRepository, TemplateResolver templateResolver)
Parameters
Type | Name | Description |
---|---|---|
System.Uri | cachedUri | The resolved URL |
ContentReference | cachedInternalObject | The data returned in internalObject, which is a page reference in this case. |
IContentRepository | contentRepository | The IContentRepository that should be used by this instance. |
PageTypeRepository | pageTypeRepository | The page type repository. |
TemplateResolver | templateResolver | The control resolver. |
Properties
FriendlyUrlExtension
Gets the friendly URL extension.
Declaration
public string FriendlyUrlExtension { get; }
Property Value
Type | Description |
---|---|
System.String | The friendly URL extension. |
UrlRewritten
Gets a value indicating whether the URL was rewritten as a result of the TryHandleUrl method.
Declaration
public bool UrlRewritten { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Methods
GetFromStartByPath(String, String, IContentRepository)
Get a page based on URL as defined by the PageData.URLSegment. Try begin with both start page and root page.
Declaration
protected static IContent GetFromStartByPath(string path, string languageId, IContentRepository contentRepository)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The friendly URL path to find a page for |
System.String | languageId | The language we prefer |
IContentRepository | contentRepository | The page repository. |
Returns
Type | Description |
---|---|
IContent | A PageData object that was found based on the URL, or NULL if not found |
Remarks
A language branch prefix will always be scanned and if found used as a language selector for the returned page
GetPageBySegments(PageReference, String[], String)
Gets the page by segments.
Declaration
[Obsolete("Use GetReferenceBySegments instead")]
protected static PageReference GetPageBySegments(PageReference rootPageRef, string[] segments, string languageCode)
Parameters
Type | Name | Description |
---|---|---|
PageReference | rootPageRef | The root page ref. |
System.String[] | segments | The segments. |
System.String | languageCode | The lang code. |
Returns
Type | Description |
---|---|
PageReference | The page as found by following the path of the segments |
GetPageFromStartByPath(String, String)
Declaration
[Obsolete("Use the version that takes a IPageRepository instance instead", true)]
protected static PageData GetPageFromStartByPath(string path, string languageId)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | |
System.String | languageId |
Returns
Type | Description |
---|---|
PageData |
GetPageFromStartByPath(String, String, IContentRepository)
Get a page based on URL as defined by the PageData.URLSegment. Try begin with both start page and root page.
Declaration
[Obsolete("Use GetFromStartByPath instaed")]
protected static PageData GetPageFromStartByPath(string path, string languageId, IContentRepository contentRepository)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The friendly URL path to find a page for |
System.String | languageId | The language we prefer |
IContentRepository | contentRepository | The page repository. |
Returns
Type | Description |
---|---|
PageData | A PageData object that was found based on the URL, or NULL if not found |
Remarks
A language branch prefix will always be scanned and if found used as a language selector for the returned page
GetReferenceBySegments(ContentReference, String[])
Gets the content by segments.
Declaration
protected static ContentReference GetReferenceBySegments(ContentReference rootPageRef, string[] segments)
Parameters
Type | Name | Description |
---|---|---|
ContentReference | rootPageRef | The root page ref. |
System.String[] | segments | The segments. |
Returns
Type | Description |
---|---|
ContentReference | The content as found by following the path of the segments |
RewriteFromCachedData(UrlRewriteContext, ref Object)
Rewrites the URL from cached data.
Declaration
public override bool RewriteFromCachedData(UrlRewriteContext context, ref object internalObject)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteContext | context | The context. |
System.Object | internalObject | The internal object. |
Returns
Type | Description |
---|---|
System.Boolean | True if the URL was rewritten, false otherwise. |
Overrides
Remarks
You may optionally return an internal representation of the page in internalObject. This will usually be a PageReference, but you should always check the type and not assume that it is a PageReference since internalObject may contain anything depending on the actual CachedUrlHandler implementation.
RewriteHierarchicalUrl(UrlRewriteContext)
Rewrites the hierarchical URL.
Declaration
protected void RewriteHierarchicalUrl(UrlRewriteContext context)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteContext | context | The context. |
TransferQueryStringsToConvertedUrl(UrlBuilder, Uri)
Transfers the query strings to converted URL.
Declaration
protected static void TransferQueryStringsToConvertedUrl(UrlBuilder externalUrl, Uri internalUri)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | externalUrl | The external URL. |
System.Uri | internalUri | The internal URI. |
TryHandleUrl(UrlRewriteContext, ref Object, ref CachedUrlHandler)
Tries to handle the URL gven in the context.
Declaration
public bool TryHandleUrl(UrlRewriteContext context, ref object internalObject, ref CachedUrlHandler handler)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteContext | context | The context for the rewrite. Note that the URL of the context may be modified. |
System.Object | internalObject | The internal object representation. |
CachedUrlHandler | handler | The cached handler. |
Returns
Type | Description |
---|---|
System.Boolean | True if the URL was recognized and handled, False otherwise. |
Remarks
If this method returns False (URL not handled), then the context, internalObject and handler should be unaffected.
If the method returns True (URL handled), then UrlRewritten will indicate if the context.Url property has been modified. The method may optionally return a CachedUrlHandler in the handler parameter in this case as well.
Returning a non-null value in handler is how you indicate that you have want to cache expensive url lookups and reuse for subsequent calls.