Last post May 06, 2011 08:58 AM by smirnov
May 05, 2011 05:52 AM|asgautm|LINK
I have a domain www.mydomain.com which exists in several languages. Until now I have overridden InitializeCulture in a aspx.cs file that inherits from Page, which are used all accross the application. Here I have programatically set the UICulture like this:
Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(myLangParam);
After this has been done, I set the langParm into a session variable, so that I retrieve this and set the UICulture correclty on all future page requests the user will be doing.
Is there any other way to remember the users selected language than using sessions? My only solution so far is to use subdomains, and determine the language out of this, but I really do not want to do that.
May 05, 2011 06:10 AM|smirnov|LINK
Well, the only way here is to add language in the url. It might be subdomains, or query string, or subdirectories in the path. You can still continue using session (as case #1), and in addition, you could check if cookies are not enabled, or client name
is like "googlebot", etc (then go for case #2). Basically, it could look like this
if (Session["lang"] != null) // case #1
lang = Session["lang"];
else // case #2
lang = Request.QueryString["lang"];
May 06, 2011 03:22 AM|asgautm|LINK
That is actually a very simple and good solution. I will use subdomains to determine the language, but only for the robots. For the normal users I will use session.
Thanks a lot:))
May 06, 2011 08:58 AM|smirnov|LINK
If a robot has indexed your site as http://en.site.com/page.aspx (english) and http://fr.site.com/page.aspx (french) then usually both links would be available in the search engine index. Therefor, a user may go to either en.site.com or fr.site.com. In this
case it would make no big sense, probably, to support keeping the selected language in the session.