Class FriendlyUrlRewriteProvider
The UrlRewriteProvider that hanldes rewriting of urls.
Inherited Members
Namespace: EPiServer.Web
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7Syntax
[Obsolete("URL Rewrite providers have been replaced with ASP.NET Routing")]
public class FriendlyUrlRewriteProvider : UrlRewriteProvider
Constructors
FriendlyUrlRewriteProvider()
Initializes a new instance of the FriendlyUrlRewriteProvider class.
Declaration
public FriendlyUrlRewriteProvider()
FriendlyUrlRewriteProvider(ILanguageBranchRepository, PageTypeRepository, TemplateResolver)
Initializes a new instance of the FriendlyUrlRewriteProvider class.
Declaration
public FriendlyUrlRewriteProvider(ILanguageBranchRepository languageBranchRepository, PageTypeRepository pageTypeRepository, TemplateResolver templateResolver)
Parameters
Type | Name | Description |
---|---|---|
ILanguageBranchRepository | languageBranchRepository | The language branch repository. |
PageTypeRepository | pageTypeRepository | The page type repository. |
TemplateResolver | templateResolver | The template resolver. |
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.
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.
ConvertToInternalInternal(UrlBuilder, ref Object)
Converts an URL to internal EPiServer-classic format. This method is the sole definition of the mapping between a rewritten "Friendly" URL and the internal format.
Declaration
protected virtual bool ConvertToInternalInternal(UrlBuilder url, ref object internalObject)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | url | The URL. |
System.Object | internalObject | The internal representation, if any. Typically may be a PageReference. |
Returns
Type | Description |
---|---|
System.Boolean | true if any conversion actually ocurred |
GetBySegments(ContentReference, String[])
Gets the page by segments.
Declaration
protected static ContentReference GetBySegments(ContentReference rootPageRef, string[] segments)
Parameters
Type | Name | Description |
---|---|---|
ContentReference | rootPageRef | The root page ref. |
System.String[] | segments | The segments. |
Returns
Type | Description |
---|---|
ContentReference | The page as found by following the path of the segments |
GetFriendlyPagePath(ContentReference, String, IContentRepository, IPermanentLinkMapper, ILanguageBranchRepository)
Gets the friendly page path.
Declaration
protected static string GetFriendlyPagePath(ContentReference contentReference, string currentLanguageBranch, IContentRepository contentRepository, IPermanentLinkMapper permanentLinkMapper, ILanguageBranchRepository languageBranchRepository)
Parameters
Type | Name | Description |
---|---|---|
ContentReference | contentReference | The page reference. |
System.String | currentLanguageBranch | The current language branch. |
IContentRepository | contentRepository | The page repository. |
IPermanentLinkMapper | permanentLinkMapper | The permanent link mapper. |
ILanguageBranchRepository | languageBranchRepository | The language branch repository. |
Returns
Type | Description |
---|---|
System.String | A path representing the page, possibly with an extension |
Exceptions
Type | Condition |
---|---|
EPiServerException | If not possible to find a Friendly path |
GetFriendlyPagePath(PageReference, String)
Gets the friendly page path.
Declaration
protected static string GetFriendlyPagePath(PageReference pageReference, string currentLanguageBranch)
Parameters
Type | Name | Description |
---|---|---|
PageReference | pageReference | The page reference. |
System.String | currentLanguageBranch | The current language branch. |
Returns
Type | Description |
---|---|
System.String | A path representing the page, possibly with an extension |
Exceptions
Type | Condition |
---|---|
EPiServerException | If not possible to find a Friendly path |
GetFromStartByPath(String, LanguageBranch)
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, LanguageBranch languageBranch)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The friendly URL path to find a page for |
LanguageBranch | languageBranch | The language branch we prefer |
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
GetHtmlRewriter()
Get's 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
GetLanguageBranchAndPath(String, ILanguageBranchRepository, out String)
Try to find if the path is prefixed with a URLSegment from a language branch
Declaration
protected static LanguageBranch GetLanguageBranchAndPath(string pathRootRelative, ILanguageBranchRepository languageBranchRepository, out string pathRelative)
Parameters
Type | Name | Description |
---|---|---|
System.String | pathRootRelative | The root-relative path to interpret |
ILanguageBranchRepository | languageBranchRepository | The language branch repository. |
System.String | pathRelative | The remaining path after root dir, language prefix, and Friendly URL extension has been removed. |
Returns
Type | Description |
---|---|
LanguageBranch | The language branch or null if not found or no globalization. |
GetLanguageBranchAndPath(String, out String)
Try to find if the path is prefixed with a URLSegment from a language branch
Declaration
protected static LanguageBranch GetLanguageBranchAndPath(string pathRootRelative, out string pathRelative)
Parameters
Type | Name | Description |
---|---|---|
System.String | pathRootRelative | The root-relative path to interpret |
System.String | pathRelative | The remaining path after root dir, language prefix, and Friendly URL extension has been removed. |
Returns
Type | Description |
---|---|
LanguageBranch | The language branch or null if not found or no globalization. |
GetPageBySegments(PageReference, String[], String)
Gets the page by segments.
Declaration
[Obsolete("Use GetBySegments 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, LanguageBranch)
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 instead")]
protected static PageData GetPageFromStartByPath(string path, LanguageBranch languageBranch)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The friendly URL path to find a page for |
LanguageBranch | languageBranch | The language branch we prefer |
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
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. |
IsVppPath(UrlBuilder, out Boolean)
Determines whether the specified URL is handled by a virtual path provider.
Declaration
protected bool IsVppPath(UrlBuilder url, out bool isModified)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | url | The URL. |
System.Boolean | isModified | if set to |
Returns
Type | Description |
---|---|
System.Boolean |
|
ShouldRewritePathForContent(IContent, UrlBuilder)
Determine if the incoming request for content
should be rewritten to url
.
Declaration
protected virtual bool ShouldRewritePathForContent(IContent content, UrlBuilder url)
Parameters
Type | Name | Description |
---|---|---|
IContent | content | The content. |
UrlBuilder | url | The URL. |
Returns
Type | Description |
---|---|
System.Boolean |
Remarks
Default implementation ony rewrites for pages. Other types of content are left untouched and thereby handled by routing.
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 if it can be dereived from the URL or the resource that is requested; otherwise null. |
System.Object | internalObject | The internal object. |
Returns
Type | Description |
---|---|
System.Boolean |
|