public override VirtualPathData GetVirtualPath(RequestContext requestContext, RouteValueDictionary values)
{
PortalRequestContext context = requestContext.HttpContext.GetPortalContext();
// Remove the "page" from the route data before rerouting
Page page = null;
if(values.ContainsKey("page")) {
// If page is present, but is null, then the user explicitly requested that no page routing be done
page = values["page"] as Page;
if(page == null) {
return null;
}
values.Remove("page");
}
// Reroute the request
VirtualPathData pathData = RerouteRequest(r => r.GetVirtualPath(requestContext, values));
if(pathData == null) {
return null; // Rerouting failed
}
// If we didn't find a page to route the request to, select the active page
if(page == null) {
page = context.ActivePage;
}
// If we still don't have a page, ignore this route
if(page == null) {
return null;
}
// Append the page path to the virtual path received and return the new path
string newVirtualPath = String.Format(CultureInfo.InvariantCulture, "{0}/{1}", page.Path.Substring(1), pathData.VirtualPath).Trim('/');
return new VirtualPathData(this, newVirtualPath);
}