Copied to clipboard

Flag this post as spam?

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


  • Colin 43 posts 143 karma points
    Apr 15, 2020 @ 07:53
    Colin
    0

    Hi

    I have two sites, USA and UK and a control which picks up a user's location.

    How do I override Umbraco so when I get the users location it redirects to the appropriate site? By that if the user location is USA it goes to USA and if UK it goes to UK.

    Thanks

  • Colin 43 posts 143 karma points
    Apr 15, 2020 @ 09:09
    Colin
    0

    A possible idea is to redirect on page load? If that's the case does anyone know if this is bad for SEO?

    Any help would be great.

  • Mila Pandurska 75 posts 349 karma points
    Apr 15, 2020 @ 09:55
    Mila Pandurska
    0

    Hi, Colin,

    you can place your redirection code in DefaultController - you can overwrite the Umbraco default controller and do the redirect there. I have done this several times. Here is the documentaion: https://our.umbraco.com/documentation/implementation/default-routing/Controller-Selection/

    I hope that this will help.

  • Colin 43 posts 143 karma points
    Apr 15, 2020 @ 10:15
    Colin
    0

    Hi Mila

    I've seen that link but it targets MVC which I'm not using for Umbraco 7. Is there another way?

    Thanks

  • Alex Skrypnyk 5730 posts 21691 karma points MVP 3x admin c-trib
    Apr 15, 2020 @ 11:23
    Alex Skrypnyk
    0

    Hi Colin, you can redirect based on IP address

    There are a few external services that can help to identify the country by IP address like https://ipstack.com/

    Thanks, Alex

  • Colin 43 posts 143 karma points
    Apr 15, 2020 @ 13:20
    Colin
    0

    Hi Alex

    I have the country from the IP address but could I just create a user control and then write an if statement to say if the country is xx then response.redirect("example.com/cc") and place this on my home template as a macro?

    Many thanks

  • Alex Skrypnyk 5730 posts 21691 karma points MVP 3x admin c-trib
    Apr 15, 2020 @ 13:21
    Alex Skrypnyk
    1

    Hi Colin,

    Yes, you can.

  • Asembli 45 posts 142 karma points
    Apr 15, 2020 @ 15:29
    Asembli
    1

    Hi,

    or implement this in IContentFinder class inside

    TryFindContent(PublishedContentRequest contentRequest)

    there trap IP or browser lang and make redirect.

    /Asembli

  • Colin 43 posts 143 karma points
    Apr 16, 2020 @ 19:54
    Colin
    0

    Thank you gents.

    Asembli - any reason why you would use IContentFinder over the web user control as a macro? For Umbraco 7 webform.

    The macro seems more easier but if there is a benefit id like to know for future please? When I researched this, it only shows code with Asp net Core. I don't know how I would go about using this.

    Thank you

  • Alex Skrypnyk 5730 posts 21691 karma points MVP 3x admin c-trib
    Apr 16, 2020 @ 21:25
    Alex Skrypnyk
    1

    The best place to do this is HTTP module because then this logic would execute before Umbraco, this is in terms of performance.

    Also, good place TryFindContent, because then this logic would execute before the page loaded - so it's faster then macro on the page that executes during page load.

    Macro - probably slowest way.

  • Colin 43 posts 143 karma points
    Apr 17, 2020 @ 13:54
    Colin
    0

    Thank you very informative.

    I have a class library project but how do I implement this in to have the existing functionality working as is but introducing this feature please?

    I'm using Umbraco 7 forms and finding it difficult to get the correct dlls and code working.

  • Alex Skrypnyk 5730 posts 21691 karma points MVP 3x admin c-trib
    Apr 17, 2020 @ 18:24
  • Alex Skrypnyk 5730 posts 21691 karma points MVP 3x admin c-trib
    27 days ago
    Alex Skrypnyk
    0

    Hi Colin,

    Please, let us which way you go and how did you solve the issue.

    Thanks,

    Alex

Please Sign in or register to post replies

Write your reply to:

Draft