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

Class RequestContextExtension

Extension methods on request Context such as et/Set Node, Lang, Controller

Inheritance
System.Object
RequestContextExtension
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
Assembly: EPiServer.dll
Version: 9.12.2
Syntax
public static class RequestContextExtension

Fields

RenderingTagName

The rendering tag name

Declaration
public static readonly string RenderingTagName
Field Value
Type Description
System.String

Methods

Gets the node from request Context.

Declaration
public static ContentReference GetContentLink(this RequestContext reqContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

Returns
Type Description
ContentReference

GetContextMode(RequestContext)

Gets the context mode.

Declaration
public static ContextMode GetContextMode(this RequestContext reqContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The request context.

Returns
Type Description
ContextMode

GetController(RequestContext)

Gets the controller name from required data on request conetxt.

Declaration
public static string GetController(this RequestContext reqContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

Returns
Type Description
System.String

GetControllerType(RequestContext)

Gets the type of the controller from the System.Web.Routing.RouteData values.

Declaration
public static Type GetControllerType(this RequestContext requestContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context containing the System.Web.Routing.RouteData values.

Returns
Type Description
System.Type

The type of the controller that is stored in the System.Web.Routing.RouteData values.

GetCustomRouteData<T>(RequestContext, String)

Gets the custom route data from request context.

Declaration
public static T GetCustomRouteData<T>(this RequestContext reqContext, string code)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

System.String code

The code.

Returns
Type Description
T
Type Parameters
Name Description
T

GetIgnorePartialRouting(RequestContext)

Gets the ignore partial routing.

Declaration
public static bool GetIgnorePartialRouting(this RequestContext reqContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

Returns
Type Description
System.Boolean

GetLanguage(RequestContext)

Gets the lang from request context.

Declaration
public static string GetLanguage(this RequestContext reqContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

Returns
Type Description
System.String

Gets the ContentReference for the "ordinary" CMS routing. This will be the root before partial routing or a page with a shortcut. In case a partial router or a page with shortcut replaces RoutedContentLink then this will contain the "ordinary" routed reference.

Declaration
public static ContentReference GetOriginalRoutedLink(this RequestContext reqContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

Returns
Type Description
ContentReference

GetRequestContext(HttpContext)

Gets the request context.

Declaration
public static RequestContext GetRequestContext(this HttpContext context)
Parameters
Type Name Description
System.Web.HttpContext context

The context.

Returns
Type Description
System.Web.Routing.RequestContext

GetRoutedData<T>(RequestContext)

Gets the data that the content route routed to from request context.

Declaration
public static T GetRoutedData<T>(this RequestContext requestContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context.

Returns
Type Description
T
Type Parameters
Name Description
T

IsInEditMode(RequestContext)

Determines if the request context is in edit mode.

Declaration
public static bool IsInEditMode(this RequestContext requestContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context

Returns
Type Description
System.Boolean
true
if the context is in edit mode; otherwise
false

Sets the content link.

Declaration
public static void SetContentLink(this RequestContext reqContext, ContentReference value)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

ContentReference value

The value.

SetContextEditMode(RequestContext)

Sets the context mode to 'edit'.

Declaration
public static void SetContextEditMode(this RequestContext reqContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The request context.

SetContextMode(RequestContext, ContextMode)

Sets the lang as custom data on request context.

Declaration
public static void SetContextMode(this RequestContext reqContext, ContextMode value)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

ContextMode value

The value.

SetController(RequestContext, String)

Sets the controller name on required data on request conetxt.

Declaration
public static void SetController(this RequestContext reqContext, string value)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

System.String value

The value.

SetControllerType(RequestContext, Type)

Sets the type of the controller in the System.Web.Routing.RouteData values.

Declaration
public static void SetControllerType(this RequestContext requestContext, Type controller)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context containing the System.Web.Routing.RouteData values.

System.Type controller

The controller.

SetCustomRouteData<T>(RequestContext, String, T)

Sets the custom route data on request context.

Declaration
public static void SetCustomRouteData<T>(this RequestContext reqContext, string code, T value)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

System.String code

The code.

T value

The value.

Type Parameters
Name Description
T

SetIgnorePartialRouting(RequestContext)

Sets the ignore partial routing.

Declaration
public static void SetIgnorePartialRouting(this RequestContext reqContext)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

SetLanguage(RequestContext, String)

Sets the lang as custom data on request conetx .

Declaration
public static void SetLanguage(this RequestContext reqContext, string value)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

System.String value

The value.

Sets the ContentReference for the "ordinary" CMS routing. This will be the root before partial routing or shortcut handling. In case a partial router or a page with shortcut replaces RoutedContentLink then this will contain the "ordinary" routed reference.

Declaration
public static void SetOriginalRoutedLink(this RequestContext reqContext, ContentReference value)
Parameters
Type Name Description
System.Web.Routing.RequestContext reqContext

The req context.

ContentReference value

The value.

SetRoutedData(RequestContext, Object)

Sets the data that the content route routed to from request context.

Declaration
public static void SetRoutedData(this RequestContext requestContext, object routedData)
Parameters
Type Name Description
System.Web.Routing.RequestContext requestContext

The request context.

System.Object routedData

The routed data.