RoutePartial Method

Assembly: EPiServer (in EPiServer.dll) Version: (

Implement to take care of partial routing below a routed content instance.


Object RoutePartial(
	TContent content,
	SegmentContext segmentContext



Type: TContent

The content that the page route has been able to route to.


Type: EPiServer.Web.Routing.Segments.SegmentContext

The segment context containing the remaining part of url.


During routing of an incoming request first the url will be parsed from left for pages as long as there is matches. If there is a remaining part (not matched by any page) after page routing then there is a check if there is any IPartialRouter registered for the the type of the found page. If so that implementation is called to se if it can route the remaining part.

An example would be an url like http://sitehost/aPage/extendedPart/extendedContent/. If there is a page matching url http://sitehost/aPage/ then if an IPartialRouter is registered for the type matching aPage that instance will be called to route the part extendedPart/extendedContent/.

Most commonly the returned data is of type TRoutedData. But there might be cases where it is something else, an example is in the Relate package where the returned object is in parameter content.


The below example is a partial router that routes URLs like 'http://sitehost/News/Sport/A%20News/'. In the example the URL part 'http://sitehost/News/' is to a page of type NewsContainer while the part 'Sport/A%20News' is handled by the partial router.

public object RoutePartial(NewsContainer content, SegmentContext segmentContext)
    //The format we handle is category/Name/
    NewsContent newsContent = null;

    //Use helper method GetNextValue to get the next part from the URL
    var nextSegment = segmentContext.GetNextValue(segmentContext.RemainingPath);

    NewsCateory category;
    if (Enum.TryParse(nextSegment.Next, out category))
        nextSegment = segmentContext.GetNextValue(nextSegment.Remaining);
        if (!String.IsNullOrEmpty(nextSegment.Next))
            newsContent = _newsStore.RouteContent(category, HttpUtility.UrlDecode(nextSegment.Next));
            if (newsContent != null)
                //Update RemainingPath so the part that we have handled is removed.
                segmentContext.RemainingPath = nextSegment.Remaining;

    return newsContent;

See Also