Specific routing

Vote:
 

Hi

i will have one pagetype under root-> startpage-> myCustomPageType

I want that when user surfs to that page and enters, after the last slash, a custom word then things will happen.

Basically, i want EPiServer to react in a special way when it comes to routing.
When user surfs to domain/{language}/{node}/{action}/{customword}
if this matches Pagetype that has controller "MyController", and action of the controller "Index"

then ActionResult(MyModel currentPage, string customword) {

// should reach this part

I have tried following

RouteTable.Routes.MapContentRoute(
"myRoute", "{language}/{node}/{action}/{productcodeid}",
new { controller = "ProductConfigurationPage", action = "productcodeindex" });

do i need to use IRoutePartial or is there a easy "one-liner" for this?

#176055
Mar 08, 2017 17:47
Vote:
 

I cannot figure it out.

I have a content area on start page.
In that content area The Catalog and products allowed to be dropped in.
I have a configuration page

When content is dopped into the content area i generate a specifik url for the links like domain/configurationpage/Product or Catalog

!!!! When the links are created somewhere else in the system then the original link to that page should be shown.

So the url rewrite should only apply to the domain/configurationpage/{custom word}


The Catalog and Product have the CatalogContentBase in common so i use that in my PartialRoute

public object RoutePartial(ProductConfigurationPageModel content, SegmentContext segmentContext)
{

var nextSegment = segmentContext.GetNextValue(segmentContext.RemainingPath);
var urlSegment = nextSegment.Next;
if (string.IsNullOrEmpty(urlSegment))
{
return null;
}
var referenceConverter = ServiceLocator.Current.GetInstance<ReferenceConverter>();
var isCommerceCatalog = referenceConverter.GetContentLink(urlSegment);
if (isCommerceCatalog != null && isCommerceCatalog.ID > 0)
{
segmentContext.RemainingPath = nextSegment.Remaining;
segmentContext.RoutedContentLink = SiteHelper.GetProductConfigurationPage().ContentLink;
return SiteHelper.GetProductConfigurationPage();
}

return null;

}


Now the tricky part is here: Catalog page do not enter here but Product page does???
How does the original GPVP do?
Also this gets hit so many time that i get System.StackOverflowException??? 
WTF?

public PartialRouteData GetPartialVirtualPath(CatalogContentBase content, string language, RouteValueDictionary routeValues,
RequestContext requestContext)
{

var contentLink = requestContext.GetRouteValue("node", routeValues) as ContentReference;

if (!content.ContentLink.CompareToIgnoreWorkID(contentLink))
{
return null;
}

if (PageEditing.PageIsInEditMode)
{
return null;
}

// DO NOT KNOW HOW TO BUILD UP A the original path to the PRoduct
var prd = new PartialRouteData
{
BasePathRoot = ????,
PartialVirtualPath = ???
};

return prd;
}

#176098
Mar 09, 2017 17:53
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.