Try our conversational search powered by Generative AI!

Can't get done with a routing problem



I have a problem with a custom route that I'm trying to configure. I saw that a very similar problem was already discussed here, for instance at this topic, but to my shame I could not understand how to deal correctly with a routes.

I have a page of type ProductDetailsPage. This page can be placed in any place of the content tree under Home/Catalog page. In ProductDetailsPageController I have an index action, that accepts parameter productUrl(it is a short friendly url token, like iphone5s_white_32gb):  public ActionResult Index(string producturl) And I want to navigate to the details page with a parameter, smth like this: http://localhost:37002/catalog/products/phones/details/blablabla where blablabla is considered as a string parameter of index action.

I've  tried to create a route like this

                          new { action = "index", phoneurl=UrlParameter.Optional});

but getting a 404 error when trying to navigate by this: http://localhost:37002/catalog/products/phones/details/blablabla link. Everytihng is ok when I'm using http://localhost:37002/catalog/products/phones/details?producturl=blablabla. How can I change the route to have a possibility to navigate without querystring?

Jun 05, 2014 16:32

I think the problem might be that your custom route start from Root page and not from Start page (that is looks for a page "catalog" under root and not under start page). You can register your route to start routing under start page instead as:

var urlSegmentRouter = ServiceLocator.Current.GetInstance<DefaultUrlSegmentRouter>();
urlSegmentRouter.RootResolver = (sd) => sd.StartPage;
MapContentRouteParameters parameters = new MapContentRouteParameters()
UrlSegmentRouter = urlSegmentRouter,

new { action = "index", phoneurl=UrlParameter.Optional},

Jun 07, 2014 22:42
* 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.