locked
Remeber the user's selected UICulture without using Session RRS feed

  • Question

  • User-608096802 posted

    Hi,

    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.

    This works fine, except that I do not want to use sessions anymore. The reason for this is that we are working to make the page search engine optimized, and the robots of search engines does not support sessions (they do not use cookies).

    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.

     

    Thanks.

     

    Asgaut

     

    Thursday, May 5, 2011 5:52 AM

Answers

  • User1508394307 posted

    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. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 6, 2011 8:58 AM

All replies

  • User1508394307 posted

    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"];
    }

    Thursday, May 5, 2011 6:10 AM
  • User-608096802 posted

    Hi Smirnov,

    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:))

     

     

    Asgaut

    Friday, May 6, 2011 3:22 AM
  • User1508394307 posted

    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. 

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, May 6, 2011 8:58 AM