We'd like to re-route requests from one EpiServer page to another, when parameters are add to the url
http://abc.com/productCategory - goes to product listings page
http://abc.com/productCategory/title/id - goes to product details page
We've implemented this so far using a Paritial Router but the correct page is not found. We followed the example here -
We can see the code being called, the correct segments are available, and the page we want to route to seems to be found and returned with no issues.
This is an example of our implementation of the router method.
public class ProductDetailsPartialRouter : IPartialRouter
public object RoutePartial(ResponsiveLandingPage content, SegmentContext segmentContext)
ProductDetailsPage productDetailsPage = SiteConfiguration.SiteSettings.ProductDetailsPage.GetPage();
if (productDetailsPage != null)
segmentContext.RoutedContentLink = productDetailsPage.ContentLink;
public PartialRouteData GetPartialVirtualPath(ProductDetailsPage content, string language, RouteValueDictionary routeValues,
Do we also implement GetPartialVirtualPath when we don't have any outgoing links?
Hmm I think you need to set the remaining path as well I think. Otherwise Episerver will keep trying to resolve it since there are still url segments left to parse...
We've tried that as well now, but are still getting the same response.
We return the page, but end up getting a 404
To Daniels note: Are you setting the remaining path to an empty string (remove you managed segment)? And is the RoutePartial method hit after you return your Product? If yes, then EPiServer may continue resolving because it's not necessarily done with the entire URL path
//The format we handle is "productname-id/"
//Use helper method GetNextValue to get the next part from the URL
var nextSegment = segmentContext.GetNextValue(segmentContext.RemainingPath);
var segments = nextSegment.Next.Split('-');
if (int.TryParse(segments.Last(), out productId))
IProduct productContent = _productStore.GetProductForCurrentUser(productId);
if (productContent != null)
//Verify if the URL is the right one
string url = this.GetUrlSegment(productContent);
//Update RemainingPath so the part that we have handled is removed.
segmentContext.RemainingPath = nextSegment.Remaining;
Above code is an example taken out of a greater context. Be aware that it haven't been tested after being altered, but I hope it can provide some guidance.
Have a good day.
Casper Aagaard Rasmussen
I've tried that as well, but still getting the same result. Even tried just setting RemainingPath to string.Empty on each call. The method gets called twice and the path value is populated both times
I'm setting segmentContext.RemainingPath, segmentContext.RoutedContentLink, and returning the page to be re-routed to.
From what you describe that you actually get to the partialrouter and that you find the content you want to route to I can't think of anything but failing to set the segmentContext.RemainingPath. If that's not it I'm officially out of ideas :)