Class ContentRoute
A route that maps an url to a structure node. When the node corresponds to a controller this the controller route value is set, otherwise the route is assumed to be a web form route.
Inheritance
Implements
Namespace: EPiServer.Web.Routing
Assembly: EPiServer.dll
Version: 9.12.2Syntax
public class ContentRoute : Route, IContentRoute
Constructors
ContentRoute()
Initializes a new instance of the ContentRoute class.
Declaration
public ContentRoute()
Remarks
This purpose of this constructor is to simplify mocking in test
ContentRoute(IRouteHandler, ISegment[], RouteValueDictionary, RouteValueDictionary, SupportedDirection, Func<RequestContext, RouteValueDictionary, String>, IViewRegistrator, IUpdateCurrentLanguage, RouteRedirector, VirtualPathHostResolver)
Initializes a new instance of the ContentRoute class.
Declaration
[Obsolete("Use alternative constructor")]
public ContentRoute(IRouteHandler routeHandler, ISegment[] urlSegments, RouteValueDictionary defaults, RouteValueDictionary constraints, SupportedDirection supportedDirection, Func<RequestContext, RouteValueDictionary, string> basePathResolver, IViewRegistrator viewRegistrator, IUpdateCurrentLanguage updateCurrentLanguage, RouteRedirector routeRedirector, VirtualPathHostResolver virtualPathHostResolver)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Routing.IRouteHandler | routeHandler | |
ISegment[] | urlSegments | |
System.Web.Routing.RouteValueDictionary | defaults | |
System.Web.Routing.RouteValueDictionary | constraints | |
SupportedDirection | supportedDirection | |
System.Func<System.Web.Routing.RequestContext, System.Web.Routing.RouteValueDictionary, System.String> | basePathResolver | |
IViewRegistrator | viewRegistrator | |
IUpdateCurrentLanguage | updateCurrentLanguage | |
RouteRedirector | routeRedirector | |
VirtualPathHostResolver | virtualPathHostResolver |
ContentRoute(IRouteHandler, ISegment[], RouteValueDictionary, RouteValueDictionary, SupportedDirection, Func<RequestContext, RouteValueDictionary, String>, IViewRegistrator, IUpdateCurrentLanguage, RouteRedirector, VirtualPathHostResolver, IContentRouteEventsRaiser, ServiceAccessor<RoutingOptions>)
Unsupported INTERNAL API! Not covered by semantic versioning; might change without notice. Initializes a new instance of the ContentRoute class.
Declaration
public ContentRoute(IRouteHandler routeHandler, ISegment[] urlSegments, RouteValueDictionary defaults, RouteValueDictionary constraints, SupportedDirection supportedDirection, Func<RequestContext, RouteValueDictionary, string> basePathResolver, IViewRegistrator viewRegistrator, IUpdateCurrentLanguage updateCurrentLanguage, RouteRedirector routeRedirector, VirtualPathHostResolver virtualPathHostResolver, IContentRouteEventsRaiser eventsRaiser, ServiceAccessor<RoutingOptions> routingOptionsAccessor)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Routing.IRouteHandler | routeHandler | |
ISegment[] | urlSegments | |
System.Web.Routing.RouteValueDictionary | defaults | |
System.Web.Routing.RouteValueDictionary | constraints | |
SupportedDirection | supportedDirection | |
System.Func<System.Web.Routing.RequestContext, System.Web.Routing.RouteValueDictionary, System.String> | basePathResolver | |
IViewRegistrator | viewRegistrator | |
IUpdateCurrentLanguage | updateCurrentLanguage | |
RouteRedirector | routeRedirector | |
VirtualPathHostResolver | virtualPathHostResolver | |
IContentRouteEventsRaiser | eventsRaiser | |
ServiceAccessor<RoutingOptions> | routingOptionsAccessor |
Properties
Name
Gets or sets the name that this ContentRoute instance was registered with.
Declaration
public string Name { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name. |
StrictLanguageRoutingResolver
Gets or sets the strict language handling resolver.
Declaration
public Func<bool> StrictLanguageRoutingResolver { get; set; }
Property Value
Type | Description |
---|---|
System.Func<System.Boolean> | The strict language handling resolver. |
Remarks
This is exposed for testability purpose. At runtime it returns StrictLanguageRouting
Url
Hides the possibility to use the 'Url' property in the Route since we do not want to use it.
Declaration
public string Url { get; set; }
Property Value
Type | Description |
---|---|
System.String |
UseTrailingSlash
Gets or sets a value indicating whether a trailing slash should be added for urls to content.
Declaration
[Obsolete("Setting should be set on RoutingOptions instance retreived from IOC")]
public static bool UseTrailingSlash { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
|
Remarks
Default value is true.
Methods
FirstIncomingRequest(HttpContextBase)
Occurs when the firsts incoming request comes to the page route.
Declaration
protected virtual void FirstIncomingRequest(HttpContextBase httpContext)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpContextBase | httpContext | The HTTP context. |
GetRouteData(HttpContextBase)
Incoming Routing
Declaration
public override RouteData GetRouteData(HttpContextBase httpContext)
Parameters
Type | Name | Description |
---|---|---|
System.Web.HttpContextBase | httpContext | Context |
Returns
Type | Description |
---|---|
System.Web.Routing.RouteData | RouteData from the incoming request |
GetValue(String, RequestContext, RouteValueDictionary)
Gets a value from a route segment from the route value dictionary, the route data values, or route data tokens
Declaration
public static object GetValue(string name, RequestContext requestContext, RouteValueDictionary values)
Parameters
Type | Name | Description |
---|---|---|
System.String | name | The name of the route segment |
System.Web.Routing.RequestContext | requestContext | Reques context |
System.Web.Routing.RouteValueDictionary | values | Route values |
Returns
Type | Description |
---|---|
System.Object | The value from the route segment. Null if there is no value |
GetVirtualPath(RequestContext, RouteValueDictionary)
Outgoing Routing
Declaration
public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Routing.RequestContext | requestContext | Context |
System.Web.Routing.RouteValueDictionary | values | Route values |
Returns
Type | Description |
---|---|
System.Web.Routing.VirtualPathData | Virtual path |
IsDirectionSupported(SupportedDirection)
Determines whether this instance supports requested route direction.
Declaration
public bool IsDirectionSupported(SupportedDirection direction)
Parameters
Type | Name | Description |
---|---|---|
SupportedDirection | direction | The direction. |
Returns
Type | Description |
---|---|
System.Boolean |
|
MatchConstraints(SegmentContext, HttpContextBase)
Checks if all constrains matches the route
Declaration
public bool MatchConstraints(SegmentContext segmentContext, HttpContextBase context)
Parameters
Type | Name | Description |
---|---|---|
SegmentContext | segmentContext | The segment context. |
System.Web.HttpContextBase | context | The context. |
Returns
Type | Description |
---|---|
System.Boolean |
OnCreatingVirtualPath(RequestContext)
Called to raise CreatingVirtualPath event.
Declaration
[Obsolete("Use the overload that also takes a RouteValueDictionary")]
protected virtual void OnCreatingVirtualPath(RequestContext requestContext)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Routing.RequestContext | requestContext | The request context. |
OnCreatingVirtualPath(RequestContext, RouteValueDictionary)
Called to raise CreatingVirtualPath event.
Declaration
protected virtual void OnCreatingVirtualPath(RequestContext requestContext, RouteValueDictionary values)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Routing.RequestContext | requestContext | The request context. |
System.Web.Routing.RouteValueDictionary | values | The route values. |
OnRoutedContent(RoutingEventArgs)
Called to raise RoutedContent event.
Declaration
protected virtual void OnRoutedContent(RoutingEventArgs routingEventArgs)
Parameters
Type | Name | Description |
---|---|---|
RoutingEventArgs | routingEventArgs | The RoutingEventArgs instance containing the event data. |
OnRoutingContent(RoutingEventArgs)
Called to raise RoutingContent event.
Declaration
protected virtual void OnRoutingContent(RoutingEventArgs routingEventArgs)
Parameters
Type | Name | Description |
---|---|---|
RoutingEventArgs | routingEventArgs | The RoutingEventArgs instance containing the event data. |
OnVirtualPathCreated(UrlBuilder)
Called to raise CreatedVirtualPath event.
Declaration
[Obsolete("Use the overload that also takes a RequestContext and a RouteValueDictionary")]
protected virtual void OnVirtualPathCreated(UrlBuilder virtualPathBuilder)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | virtualPathBuilder | The virtual path builder. |
OnVirtualPathCreated(UrlBuilder, RequestContext, RouteValueDictionary)
Called to raise CreatedVirtualPath event.
Declaration
protected virtual void OnVirtualPathCreated(UrlBuilder virtualPathBuilder, RequestContext requestContext, RouteValueDictionary routeValues)
Parameters
Type | Name | Description |
---|---|---|
UrlBuilder | virtualPathBuilder | The virtual path builder. |
System.Web.Routing.RequestContext | requestContext | The request context. |
System.Web.Routing.RouteValueDictionary | routeValues | The route values. |
RouteSegmentContext(SegmentContext)
Tries to route the specified segmentContext
to an content instance.
Declaration
public virtual RouteData RouteSegmentContext(SegmentContext segmentContext)
Parameters
Type | Name | Description |
---|---|---|
SegmentContext | segmentContext | The segment context. |
Returns
Type | Description |
---|---|
System.Web.Routing.RouteData | RouteData if routing succeds else null |
Events
CreatedVirtualPath
Raised when outgoing virtual path has been created.
Declaration
[Obsolete("Use IContentRouteEvents.CreatedVirtualPath instead")]
public static event EventHandler<UrlBuilderEventArgs> CreatedVirtualPath
Event Type
Type | Description |
---|---|
System.EventHandler<UrlBuilderEventArgs> |
CreatingVirtualPath
Raised when outgoing virtual path is trying to be created by a route.
Declaration
[Obsolete("Use IContentRouteEvents.CreatingVirtualPath instead")]
public static event EventHandler<RequestContextEventArgs> CreatingVirtualPath
Event Type
Type | Description |
---|---|
System.EventHandler<RequestContextEventArgs> |
RoutedContent
Raised when an incoming request have been routed to a content instance.
Declaration
[Obsolete("Use IContentRouteEvents.RoutedContent instead")]
public static event EventHandler<RoutingEventArgs> RoutedContent
Event Type
Type | Description |
---|---|
System.EventHandler<RoutingEventArgs> |
RoutingContent
Raised when outgoing virtual path has been created.
Declaration
[Obsolete("Use IContentRouteEvents.RoutingContent instead")]
public static event EventHandler<RoutingEventArgs> RoutingContent
Event Type
Type | Description |
---|---|
System.EventHandler<RoutingEventArgs> |
Explicit Interface Implementations
IContentRoute.get_Defaults()
Declaration
RouteValueDictionary IContentRoute.get_Defaults()
Returns
Type | Description |
---|---|
System.Web.Routing.RouteValueDictionary |
IContentRoute.set_Defaults(RouteValueDictionary)
Declaration
void IContentRoute.set_Defaults(RouteValueDictionary value)
Parameters
Type | Name | Description |
---|---|---|
System.Web.Routing.RouteValueDictionary | value |