I have a specific requirement where I don't want a user to be able to change the culture they are viewing. Other than a login page the site is entirely authenticated, so for all important pages I will always have a logged in user. What I want to do is check the assigned culture for the user against the current culture, and if it is different, force to the user's culture.
I have something working with the URL Rewriting event 'ProcessRewritingResult.Before'. It isn't perfect, and I'm wondering if there is actually a better way of doing it.
I have the URLs setup so the culture is in the url like this:
For Australia: /au/blahblahbpage
For Brazil: /br/blhablahpage
In the rewrite event I just create a new path to the correct one and set context.RewritePath.
The content displaying on the page is correct if I do this, but the URL actually doesn't change. So let's say the user is set to Australia and I manually change the url to be /br instead, my code fixes it so the Australian content shows, but the url still has /br. On the next request, the url is correctly showing /au.
I'd love it if I can get the url correct as well as the content.
It would be even better if there were an easier way of just setting lang=en-AU (for example) and having the url handled by Kentico instead of doing what I'm doing. It seems sort of like a hack instead of a real way of changing the culture.
Thanks for your help!