Why is my Sitecore.Context.Language reloading in the controller?

Sitecore seems to be doing something weird with the language variable in this Context object. If I load the CMS page using url ?sc_Lang=ru-RU (get the Russian version of my site), by the time it returns to my MVC controller, reset will return to en

 public PartialViewResult Navigation() { //en var language = Sitecore.Context.Language; } 

I know that sitecore does install this at some point, because if I add the HTTP pipeline, I can see Sitecore.Context.Language as ru-RU :

 public class LanguageResolver { public void Process(Sitecore.Pipelines.HttpRequest.HttpRequestArgs args) { //ru-RU var language = Sitecore.Context.Language; } } 

Registered:

 <processor type="Sitecore.Pipelines.HttpRequest.ItemResolver, Sitecore.Kernel"/> <processor type="namespace.LanguageResolver,RR.Web.Sc.Extensions" patch:source="Languages.config"/> 

as recommended in the sitecore blog post

I did a bit of work at sitecore dlls, and I noticed that Sitcore.Context.Language is basically a wrapper for HttpContext.Current.Items["sc_Language"] . When I check this, I see the same results (i.e. in the pipeline it is ru-RU in the en controller)

So somewhere, it turns this HttpContext Item into "en" .

As an experiment, I dumped a new variable into the Items collection. Then I can see it again (in the correct state) in the controller, so the Items collection will be correctly passed to the controller.

I did not initially develop this site, but I do not see anywhere in the code base that modifies this language variable.

Has anyone else experienced this? Anything I missed? What do I need to configure, check?

Sitecore docs (as usual) are pretty sad in this matter.


To follow the comment from @jammykam:

I see a cookie lang Response Set-Cookie: redrow#lang=ru-RU; path=/ Set-Cookie: redrow#lang=ru-RU; path=/ and languages ​​are configured:

enter image description here

enter image description here

+5
source share

Source: https://habr.com/ru/post/1235198/


All Articles