Querystring in MVC routing

Vote:
 

Hi,

I need to rewrite the default routing to my custom url structure, with help from EPiServer Devs I am able to make it work as expect. However, I have a paging which I want the URL to something like Mydomain.com/structure/2/ 2 is the page number here but it shows me Mydomain.com/structure?currentpagenumber = 2, do I need to write a new segment for currentpagenumber?

Thanks in advance,

Hai

 

#69573
Mar 28, 2013 7:16
Vote:
 

No, you don't need to do that. Just add the following to you're registered route: .../{currentPageNumber}. Now you can have a parameter on you're controller with the same name.

#69577
Mar 28, 2013 8:25
Vote:
 

Thank you Jonas!

It worked like a charm! However I need to add a ParameterSegment to the MapContentRouteParameters to make it work:

var parameters = new MapContentRouteParameters
{
SegmentMappings = new Dictionary<string, ISegment>(),
Direction = SupportedDirection.Both
};

var pageNumberParameter = new ParameterSegment("currentPageNumber");

routes.MapContentRoute(
name: "pagenumber",
url: "{currentPageNumber}/{node}/{action}",
defaults: new { action = "index" },
parameters: parameters);

By the way, I have another question, is there anyway to hide the parameter in the url, I have another parameter, but dont want to show it in the url, how can I do that?

Regards,

Hai

#69581
Mar 28, 2013 9:20
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.