Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Filur 20 posts 154 karma points
    May 16, 2017 @ 09:34
    Filur
    0

    Route hijacking vs content finder

    Hello,

    I would like to route all requests to its corresponding controllers index method, e.g. localhost/Home/bar and localhost/Home/bar/baz should go to the Home controller Index() method. locahost/About/foo/bar/baz should route to the About controller's Index method etc.

    The reason is that I use a client side router on each page which takes care of the "deeper" routes. I tried adding a routing rule to "catch all", i.e. {controller/*.}, but if I use it my RenderModel is null on my requests.

    What is more suitable here, a custom content finder or route hijacking?

    Please let me know if I need to elaborate anything. Thanks!

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    May 16, 2017 @ 10:59
    David Brendel
    0

    Hi Filur,

    depends if you have specific custom routes or if you have undefined amount of custom routes.

    My suggestion would be ContentFinder when you want to do specific stuff depending on a substring in the url and you know they are names of nodes.

    Or maybe look at doing custom routing and add routes to the route table and then have a look at a custom UmbracoVirtualNodeRouteHandler implementation.

    Maybe have a look at this blog post to get familiar with the content finder: https://24days.in/umbraco-cms/2014/urlprovider-and-contentfinder/

    Regards David

  • Filur 20 posts 154 karma points
    May 16, 2017 @ 11:14
    Filur
    0

    Hi David,

    Thanks for the reply.

    I would say undefined in this case. Or at least I would prefer to explicitly specify them.

    Perhaps I can use the content finder to extract the controller fragment, e.g. Home, from the URL, then return the appropriate content? Then the default routing would trigger the corresponding view and controller with the default conventions, right (the Home view and controller in this case)?

  • David Brendel 792 posts 2970 karma points MVP 3x c-trib
    May 16, 2017 @ 14:14
    David Brendel
    100

    Hi Filur,

    yes that's what I would try to do. Build a content finder. Check the url for matching terms (node name or whatever you want) and then return the correct node in the content finder so that it gets rendered.

    Regards David

  • Filur 20 posts 154 karma points
    May 16, 2017 @ 15:48
    Filur
    0

    Allright, thanks for the input David!

Please Sign in or register to post replies

Write your reply to:

Draft