Try our conversational search powered by Generative AI!

Class UrlRewriteContext

Context class for URL rewriting by the HierarchicalUrlHandler and related classes.

Inheritance
System.Object
UrlRewriteContext
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: EPiServer.Web
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
public class UrlRewriteContext

Constructors

UrlRewriteContext(UrlBuilder)

Initializes a new instance of the UrlRewriteContext class.

Declaration
public UrlRewriteContext(UrlBuilder url)
Parameters
Type Name Description
UrlBuilder url

The URL.

Properties

CleanPath

Gets the clean path.

Declaration
public string CleanPath { get; }
Property Value
Type Description
System.String

The clean path.

Remarks

The Clean path is defined as the path without the RootDir prefix, without any language prefix and a possible trailing slash has been stripped.

HasTrailingSlash

Gets a value indicating whether the URL has a trailing slash.

Declaration
public bool HasTrailingSlash { get; }
Property Value
Type Description
System.Boolean

true if this instance has trailing slash; otherwise, false.

IsValidPath

Gets a value indicating whether the URL is a valid path for rewriting.

Declaration
public bool IsValidPath { get; }
Property Value
Type Description
System.Boolean

true if this instance is a valid path; otherwise, false.

Remarks

To be considered valid, the URL must start with the value given in RootDir to identify it as belonging to the curren web application.

Language

Gets the language that is associated with this URL.

Declaration
public CultureInfo Language { get; }
Property Value
Type Description
System.Globalization.CultureInfo

The language.

Remarks

Note that this will only indicate language preference based on the URL. Other factors, such as user preferences, cookies etc may override the language defined in the URL.

Languages

Gets the languages enabled on site.

Declaration
public static IDictionary<string, CultureInfo> Languages { get; }
Property Value
Type Description
System.Collections.Generic.IDictionary<System.String, System.Globalization.CultureInfo>

RootDir

Gets or sets the root directory for the current web site.

Declaration
public static string RootDir { get; set; }
Property Value
Type Description
System.String

The root dir.

Remarks

Rather than accessing external configuration, this information is injected into the context class for testability and performance reasons.

Url

Gets the URL that should be rewritten.

Declaration
public UrlBuilder Url { get; }
Property Value
Type Description
UrlBuilder

The URL.

Methods

InitializeLanguageResolving(IEnumerable<LanguageBranch>)

Initializes the language resolving.

Declaration
public static void InitializeLanguageResolving(IEnumerable<LanguageBranch> enabledLanguages)
Parameters
Type Name Description
System.Collections.Generic.IEnumerable<LanguageBranch> enabledLanguages

The enabled languages.

Remarks

The first segment of a hierarchical URL usually identifies the language. Calling this method with a list of language branches initializes the data structures needed to handle the resolving of language segments into actual language.

Extension Methods