November Happy Hour will be moved to Thursday December 5th.

Class SegmentContext

Encapsulates information about a HTTP/Url request that is used when determining segments during routing.

Inheritance
System.Object
SegmentContext
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.Routing.Segments
Assembly: EPiServer.Cms.AspNet.dll
Version: 11.20.7
Syntax
public abstract class SegmentContext

Constructors

SegmentContext(Uri)

Initializes a new instance of the SegmentContext class.

Declaration
protected SegmentContext(Uri requestUrl)
Parameters
Type Name Description
System.Uri requestUrl

The request URL.

Properties

ContentLanguage

Gets or sets the language for the content that was routed to.

Declaration
public virtual string ContentLanguage { get; set; }
Property Value
Type Description
System.String
Remarks

Note that ContentLanguage and Language might be differ since Language also takes language segment and language host mapping in consideration.

ContextMode

Gets or sets the context mode for the route.

Declaration
public virtual ContextMode ContextMode { get; set; }
Property Value
Type Description
ContextMode

Defaults

Gets or sets the values to use if the URL does not contain all the parameters.

Declaration
public virtual RouteValueDictionary Defaults { get; set; }
Property Value
Type Description
System.Web.Routing.RouteValueDictionary

Language

This property states the language for the route.

Declaration
public virtual string Language { get; set; }
Property Value
Type Description
System.String

LastConsumedFragment

Gets or sets the last consumed fragment.

Declaration
public virtual string LastConsumedFragment { get; set; }
Property Value
Type Description
System.String

The last consumed fragment.

Remarks

This value is updated when RemainingPath is updated.

MatchContentRouteConstraints

This property is used to indicate whether we should match content route constraints when routing.

Declaration
public virtual bool MatchContentRouteConstraints { get; set; }
Property Value
Type Description
System.Boolean

QueryString

Gets the query string for the route.

Declaration
public abstract NameValueCollection QueryString { get; }
Property Value
Type Description
System.Collections.Specialized.NameValueCollection

RedirectShortcutPages

Gets or sets if routes to pages that is set as shortcut to other page should be redirected.

Declaration
public Func<bool> RedirectShortcutPages { get; set; }
Property Value
Type Description
System.Func<System.Boolean>
Remarks

This is exposed for testability purpose. At runtime it uses UseLegacyShortcutRouting.

RemainingPath

This property is used to keep track of what parts of URL that has been handled by different segments.

Declaration
public virtual string RemainingPath { get; set; }
Property Value
Type Description
System.String
Remarks

LastConsumedFragment is updated when this property is set. When overriding this update LastConsumedFragment as well.

RequestUrl

Gets the request URI that is routed.

Declaration
public Uri RequestUrl { get; }
Property Value
Type Description
System.Uri

The request URI.

RouteData

Gets or sets the route data.

Declaration
public virtual RouteData RouteData { get; set; }
Property Value
Type Description
System.Web.Routing.RouteData

This property states the ContentReference for the route.

Declaration
public virtual ContentReference RoutedContentLink { get; set; }
Property Value
Type Description
ContentReference

RoutedObject

Gets or sets the route data.

Declaration
public virtual object RoutedObject { get; set; }
Property Value
Type Description
System.Object

RoutedSiteDefinition

Gets or sets the site definition that matches the route.

Declaration
public virtual SiteDefinition RoutedSiteDefinition { get; set; }
Property Value
Type Description
SiteDefinition

StrictLanguageRoutingResolver

Gets or sets the strict language handling resolver.

Declaration
public Func<bool> StrictLanguageRoutingResolver { get; set; }
Property Value
Type Description
System.Func<System.Boolean>
Remarks

This is exposed for testability purpose. At runtime it returns StrictLanguageRouting

Methods

Copy()

Copies this instance.

Declaration
public abstract SegmentContext Copy()
Returns
Type Description
SegmentContext

GetCustomRouteData<T>(String)

Gets custom route data from context.

Declaration
public virtual T GetCustomRouteData<T>(string code)
Parameters
Type Name Description
System.String code

The code.

Returns
Type Description
T
Type Parameters
Name Description
T

GetNextValue(String)

Finds the next value in the URL by looking for the forward slash character.

Declaration
public SegmentPair GetNextValue(string remainingPath)
Parameters
Type Name Description
System.String remainingPath

The URL to get next value from.

Returns
Type Description
SegmentPair

A SegmentPair containing the next value and the calculated remaining url.

PermanentRedirect(String)

Does a permanent redirect.

Declaration
public virtual void PermanentRedirect(string url)
Parameters
Type Name Description
System.String url

The URL.

SetCustomRouteData<T>(String, T)

Sets custom route data in context.

Declaration
public virtual void SetCustomRouteData<T>(string code, T value)
Parameters
Type Name Description
System.String code

The code.

T value

The value.

Type Parameters
Name Description
T

TemporaryRedirect(String)

Does a temporary redirect.

Declaration
public virtual void TemporaryRedirect(string url)
Parameters
Type Name Description
System.String url

The URL.

Extension Methods