Class UrlRewriteProvider
Provide basic URL rewrite functionality, mapping to and from an internal format.
Inheritance
Namespace: EPiServer.Web
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7Syntax
public abstract class UrlRewriteProvider : ProviderBase
Remarks
The mapping performed is context-free in the sense that it just maps from internal or to internal, it does not rebase relative URLs dependning on the internal and external requesting context URL.
Examples
Get a friendly URL for the given PageData object. Returns the friendly Url for the given PageData object.
Constructors
UrlRewriteProvider()
Declaration
protected UrlRewriteProvider()
Properties
Description
Gets a brief, friendly description suitable for display in administrative tools or other user interfaces (UIs).
Declaration
public override string Description { get; }
Property Value
Type | Description |
---|---|
System.String | A brief, friendly description suitable for display in administrative tools or other UIs. |
ExcludedPaths
Gets a list of all the excluded paths.
Declaration
public static IEnumerable<string> ExcludedPaths { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.IEnumerable<System.String> | The excluded paths. |
FriendlyUrlExtension
Gets the extension used for friendly URL generation.
Declaration
public static string FriendlyUrlExtension { get; }
Property Value
Type | Description |
---|---|
System.String | The friendly URL extension. |
IsFurlEnabled
Indicates if FURL (Friendly url) is enabled.
Declaration
public static bool IsFurlEnabled { get; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
This property will be set from UrlRewriteModuleBase when it is initialized. So if an httpModule that inherits from UrlRewriteModuleBase is registered as an httpModule this returns true otherwise false
Module
Get the UrlRewriteModule instance currently executing
Declaration
public static UrlRewriteModuleBase Module { get; }
Property Value
Type | Description |
---|---|
UrlRewriteModuleBase |
PermanentLinkMapper
Gets or sets the permanent link mapper to use.
Declaration
public IPermanentLinkMapper PermanentLinkMapper { get; set; }
Property Value
Type | Description |
---|---|
IPermanentLinkMapper | The permanent link mapper. |
RebaseKind
Gets the kind of rebase to perform for URLs
Declaration
public static RebaseKind RebaseKind { get; }
Property Value
Type | Description |
---|---|
RebaseKind | The kind of rebase. |
RootDir
Gets the absolute path to the EPiServer root directory.
Declaration
public static string RootDir { get; }
Property Value
Type | Description |
---|---|
System.String | The root dir. |
UrlPreventRewriteAttribute
Gets the attribute used for prevent rewriting of url:s.
Declaration
public static string UrlPreventRewriteAttribute { get; }
Property Value
Type | Description |
---|---|
System.String | The friendly URL extension. |
Methods
AddExcludedPath(String)
Adds a path to the excluded list.
Declaration
public static void AddExcludedPath(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path. |
ClearExcludedPaths()
Clears the excluded paths information.
Declaration
public static void ClearExcludedPaths()
ConvertToExternal(UrlBuilder, Object, Encoding)
Converts from internal, without regard to the context of internal/external URL.
Declaration
public abstract bool ConvertToExternal(UrlBuilder url, object internalObject, Encoding toEncoding)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | url | The URL to possibly convert |
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 |
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.
ConvertToExternal(UrlBuilder, Object, Encoding, Boolean)
Converts from internal, without regard to the context of internal/external URL.
Declaration
public virtual bool ConvertToExternal(UrlBuilder url, object internalObject, Encoding toEncoding, bool forceIsInEditMode)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | url | The URL to possibly convert |
System.Object | internalObject | An optional internal representation of the URL, typically a PageReference |
System.Text.Encoding | toEncoding | The current encoding |
System.Boolean | forceIsInEditMode | if set to |
Returns
Type | Description |
---|---|
System.Boolean | true if any modifications were made |
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.
ConvertToInternal(UrlBuilder)
Converts to internal, without regard to the context of internal/external URL.
Declaration
public bool ConvertToInternal(UrlBuilder url)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | url | The URL. |
Returns
Type | Description |
---|---|
System.Boolean | true if any modifications were made |
ConvertToInternal(UrlBuilder, out Object)
Converts to internal, without regard to the context of internal/external URL.
Declaration
public abstract 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 |
Remarks
There is no support for changing encoding when converting to internal, since there is no requirement for this.
CreateInstance(ProviderSettings)
Creates an Instance of the registered/configured UrlRewriteProvider. Before instance can be created Reflection API is used to determine if configured class meets the minimun requirements in semantics.
Declaration
public static UrlRewriteProvider CreateInstance(ProviderSettings providerSettings)
Parameters
Type | Name | Description |
---|---|---|
System.Configuration.ProviderSettings | providerSettings |
Returns
Type | Description |
---|---|
UrlRewriteProvider |
GetHtmlRewriter()
Gets an instance of a HTML-rewriter to use when emitting HTML from EPiServer.
Declaration
public abstract HtmlRewriteToExternal GetHtmlRewriter()
Returns
Type | Description |
---|---|
HtmlRewriteToExternal | A new instance of a HtmlRewriteToExternal-derived class |
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. |
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. |
IsExcludedPath(String)
Determines whether the specified path is a path excluded from URL rewriting.
Declaration
public static bool IsExcludedPath(string path)
Parameters
Type | Name | Description |
---|---|---|
System.String | path | The path. |
Returns
Type | Description |
---|---|
System.Boolean |
|
OnConvertedToExternal(UrlRewriteEventArgs)
Raises the ConvertedToExternal event.
Declaration
protected virtual void OnConvertedToExternal(UrlRewriteEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteEventArgs | e | The UrlRewriteEventArgs instance containing the event data. |
OnConvertedToInternal(UrlRewriteEventArgs)
Raises the ConvertedToInternal event.
Declaration
protected virtual void OnConvertedToInternal(UrlRewriteEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteEventArgs | e | The UrlRewriteEventArgs instance containing the event data. |
OnConvertingToExternal(UrlRewriteEventArgs)
Raises the ConvertingToExternal event.
Declaration
protected virtual void OnConvertingToExternal(UrlRewriteEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteEventArgs | e | The UrlRewriteEventArgs instance containing the event data. |
OnConvertingToInternal(UrlRewriteEventArgs)
Raises the ConvertingToInternal event.
Declaration
protected virtual void OnConvertingToInternal(UrlRewriteEventArgs e)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteEventArgs | e | The UrlRewriteEventArgs instance containing the event data. |
TryConvertPermanentLink(UrlBuilder, out ContentReference)
Tries to convert a link as a guid based link (permanent link).
Declaration
protected virtual bool TryConvertPermanentLink(UrlBuilder url, out ContentReference contentLink)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | url | The URL. |
ContentReference | contentLink | The page link. If the permanent link references a page, then the page reference is returned. |
Returns
Type | Description |
---|---|
System.Boolean |
TryConvertToInternal(UrlBuilder, out CultureInfo, out Object)
Converts to internal, without regard to the context of internal/external URL.
Declaration
public virtual 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 |
Remarks
There is no support for changing encoding when converting to internal, since there is no requirement for this.
ValidateRewriteToExternal(UrlRewriteEventArgs, String)
Validates if the url should be rewritten to external format.
Declaration
public virtual void ValidateRewriteToExternal(UrlRewriteEventArgs e, string basePath)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteEventArgs | e | The UrlRewriteEventArgs instance containing the event data. |
System.String | basePath | The base path. |
ValidateRewriteToInternal(UrlRewriteEventArgs, String)
Validates if the url should berewritten to internal format.
Declaration
public virtual void ValidateRewriteToInternal(UrlRewriteEventArgs e, string basePath)
Parameters
Type | Name | Description |
---|---|---|
UrlRewriteEventArgs | e | The UrlRewriteEventArgs instance containing the event data. |
System.String | basePath | The base path. |
Events
ConvertedToExternal
Raised when we've done the conversion.
Declaration
public event EventHandler<UrlRewriteEventArgs> ConvertedToExternal
Event Type
Type | Description |
---|---|
System.EventHandler<UrlRewriteEventArgs> |
ConvertedToInternal
Raised when we've done the conversion.
Declaration
public event EventHandler<UrlRewriteEventArgs> ConvertedToInternal
Event Type
Type | Description |
---|---|
System.EventHandler<UrlRewriteEventArgs> |
ConvertingToExternal
Raised just before we're about to convert.
Declaration
public event EventHandler<UrlRewriteEventArgs> ConvertingToExternal
Event Type
Type | Description |
---|---|
System.EventHandler<UrlRewriteEventArgs> |
ConvertingToInternal
Raised just before we're about to convert.
Declaration
public event EventHandler<UrlRewriteEventArgs> ConvertingToInternal
Event Type
Type | Description |
---|---|
System.EventHandler<UrlRewriteEventArgs> |