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 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.
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.
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.
I've seen that link but it targets MVC which I'm not using for Umbraco 7. Is there another way?
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/
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?
Yes, you can.
or implement this in IContentFinder class inside
there trap IP or browser lang and make redirect.
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.
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.
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.
1) IContentFinder example - https://our.umbraco.com/Documentation/Reference/Routing/Request-Pipeline/IContentFinder-v7
2) HTTP module example - https://www.codeproject.com/Articles/32475/Asp-net-HTTP-Modules
Please, let us which way you go and how did you solve the issue.
is working on a reply...
Write your reply to:
Image will be uploaded when post is submitted