Copied to clipboard

Flag this post as spam?

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


  • Jojo V 11 posts 81 karma points
    Jul 18, 2019 @ 08:45
    Jojo V
    0

    Hi,

    I look for how to get content (ideal from cache) by URL with multiple hostnames in custom API controller UmbracoApiController. I was find method UmbracoContext.Content.GetByRoute but I don't know how to get content for specific hostname / domain.

    For example, how find content for example.com/en/home and anotherdomain.com/en/home. Content this pages is not the same.

    If i set this url to parameter in function UmbracoApiController then I always getnull or error.

    Thanks.

  • Marc Goodson 940 posts 6250 karma points MVP 4x c-trib
    29 days ago
    Marc Goodson
    1

    Hi Jojo

    If you have specific multiple custom hostnames set on your Umbraco site to different root nodes in the content tree - then you can still use GetByRoute..

    but you need to prefix the relative path you are looking for with the id of the Root node for that site domain..

    So GetByRoute("1234/en/home") and GetByRoute("1235/en/home")

    where 1234 is the id of root node for one site, and 1235 is the root node for another...

    I know this is a V7 package PageNotFoundManager by TimGeyssens, but this code gives you a bit of a gist of how the GetByRoute works in a multi site Umbraco implementation.

    https://github.com/TimGeyssens/UmbracoPageNotFoundManager/blob/master/PageNotFoundManager/PageNotFoundContentFinder.cs

    Hope that helps steer in the right direction.

    regards

    marc

Please Sign in or register to post replies

Write your reply to:

Draft