Try our conversational search powered by Generative AI!

IPartialRouter and UrlResolverContext RouteValues



Have a question about CMS 12 partial routing and passing parameters around. I see that it's possible to use RouteValues, e.g. like this:

public object RoutePartial(MyDearPage content, UrlResolverContext segmentContext)
	var segment1 = segmentContext.GetNextSegment(segmentContext.RemainingSegments);	
	segmentContext.RouteValues["dearPageSegment1"] = segment1.Next.ToString(); //here I'm adding my things to RouteValues
	return content;

My problem is that I don't see a way how to access these UrlResolverContext.RouteValues later on, e.g. in the PageCotroller? Anyone knows what would be the right way to use / access them? 

Mar 23, 2023 12:25

Hi Janis

What if you add "dearPageSegment1" as a parameter to your action method? Like Index(string dearPageSegment1).

Mar 23, 2023 20:01

Nope, unfortunately, didn't work :/. Found a workaround where I'm passing around my path parameters in the page model. 

Edited, Mar 26, 2023 16:58

Have you tried to overriding/writing a custom implementation of the IUrlSegmentRouter interface?

Edited, Mar 27, 2023 7:34

This is late but I would like adding a remark for later reference.

I think the updated UrlResolverContext' RouteValues should be available again for reading through a certain context-relatared service but currently have no idea how to do that.

As see, the HttpContext.Items is available through the pipeline from the IPartialRouter inheritance then to the Controller so we can use the HttpContext.Items property instead for passing desired values between the pipeline stages.

Edited, Aug 07, 2023 7:32
* 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.