I got a website where i want to switch language and it redirects to same page on that language.
We got it setup that each language got a channel:
hostname/sv
hostname/en
So if I am on page: hostname/en/about-us i want to redirect to: hostname/sv/om-oss.
I have done this by using:
requestModel.CurrentPageModel.SystemId
PageService
ChannelService
UrlService
Though when a user is on a category or product page the SystemId above will not point to that “Page”.
I’m thinking i need to get the Category and BaseProduct Ids somehow and use respective service to then use with UrlService? How would i go for that the best way, or is there another service where i can transform from currentUrl => “page”.
In general, don’t use the ‘HttpContect.Current’ to find information, use the ‘*Accessors’ classes instead to not get breaking changes in you application if the internal storage for them is changed.
I also see that I missed to mention, I used the PageModel, CategoryModel, ProductModel in LayoutController to get the Id’s I wanted to the HeaderViewModel that is used for header.cshtml.