SaaS CMS has officially launched! Learn more now.

Querystring in MVC routing



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 2 is the page number here but it shows me = 2, do I need to write a new segment for currentpagenumber?

Thanks in advance,



Mar 28, 2013 7:16

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.

Mar 28, 2013 8:25

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");

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?



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.
* 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.