Press Ctrl / CMD + C to copy this to your clipboard.
This post will be reported to the moderators as potential spam to be looked at
I'm trying to set up routing so that I can use route segments in place of a query string, to allow things like this:
/news/{type}/{topic} - where topic is used to filter a search
It's much more user-friendly than news?topic=value or news?person=name
I've added the required route:
routes.MapUmbracoRoute("NewsListRoute", "news/{type}/{filter}", new { controller = "News", action = "FilteredNews", filter = UrlParameter.Optional }, new NewsListRouteHandler(), new { type = "^(about|featuring)$" });
and the handler:
protected override IPublishedContent FindContent(RequestContext request, UmbracoContext context) { return context.ContentCache.GetById(KnownDocumentId.NewsIndex); }
That all works fine - the request is routed to the controller and returns the render model back to the client.
BUT...
The displayed URL changes from /news/about/thing to /news, which is the instance returned by the handler.
How do I serve the node at /news at the custom route /news/{type}/{filter}?
Hey Nathan,
Not sure if it would work, but what about https://our.umbraco.com/packages/website-utilities/autoroutetemplate/
Nik
That looks like it does pretty much exactly what I need - wanted to avoid any backoffice setup, but won't lose sleep over it...
is working on a reply...
Write your reply to:
Upload image
Image will be uploaded when post is submitted
Maintaining requested URL with virtual node route handling
I'm trying to set up routing so that I can use route segments in place of a query string, to allow things like this:
/news/{type}/{topic} - where topic is used to filter a search
It's much more user-friendly than news?topic=value or news?person=name
I've added the required route:
and the handler:
That all works fine - the request is routed to the controller and returns the render model back to the client.
BUT...
The displayed URL changes from /news/about/thing to /news, which is the instance returned by the handler.
How do I serve the node at /news at the custom route /news/{type}/{filter}?
Hey Nathan,
Not sure if it would work, but what about https://our.umbraco.com/packages/website-utilities/autoroutetemplate/
Nik
That looks like it does pretty much exactly what I need - wanted to avoid any backoffice setup, but won't lose sleep over it...
is working on a reply...