Sitecore and dev#lang cookie

I observed what seemed to be a bit strange behavior in a Sitecore 7.2 implementation, I reasontly joined. The strange behavior was only in one of my colleague dev environments (it works on my machine – or actually it, did but not on my colleague).

When the site tried to resolve some specific urls, the last part of the url (after the domain), was solved as the context language. This resulting in a cookie named dev#local was set with a value containing the last part of the url (Eg. If the url was www.mydomain.com/om-Godt the value of the dev#local cookie was set to “om-Godt”.



Since the language “om-Godt” didn’t exist, the site redirected to an error page. 


Funny though, because it was not all the time a page was rendered. Anyway, copying a language value into the url (www.mydomain.com/en/contact-us) the site resolved correctly. After clarifying this, it was pretty obvious where to go next. We verified the “languageEmbedding” was set to “Never” in the LinkManager setting. Just to make sure, it was handled consistently in the solution.

<add name="sitecore" type="Sitecore.Links.LinkProvider, Sitecore.Kernel" 
addAspxExtension="false" alwaysIncludeServerUrl="false" encodeNames="true" 
languageEmbedding="Never" languageLocation="filePath" lowercaseUrls="false" 
shortenUrls="true" useDisplayName="false" />


We located the Languages.AlwasyStripLanguage setting in the web.config file (it was a 7.2 solution) and verified the setting was set to true. We created an include file for the setting and set it to false.


      <!--  LANGUAGES ALWAYS STRIP LANGUAGE
      This setting specifies if the StripLanguage processor in the <preprocessRequest> pipeline will parse and remove languages from
      the URL, even when the languageEmbedding attribute of the linkProvider is set to "never". You should only change this setting 
      to "false" if the default behavior causes problems in your solution.
      Default value: true 
-->
      <setting name="Languages.AlwaysStripLanguage" value="true" />


After that the language was solved correctly though out the solution.

No comments: