Hello, We're using EpiServer 7 Patch 3 and we're trying to use cookies instead of url designators (/en/ or ?epslanguage=en) to store visitors' language preference. We found that EpiServer's routing logic fails to take the language cookie into account when multiple versions of a page have the same url. For example: page X is available in both en (English) and da (Danish) via the urls: - en: /Test/ - da: /Test/ The URL http://domain/Test/ would always return English even when the cookie epslanguage is set to da.
Looking at the routing logics through a decompiler led me to believe that this line in ResolveContentForIncoming() from EPiServer.Web.Routing.Segments.DefaultUrlSegmentRouter was responsible:
The call to GetRoutingSegments() returns all the language branches but it did not prioritize the list in any way. The subsequent call to FirstOrDefault() simply takes the first branch which might or might not match the visitor's current language. We're working around this bug by injecting in our custom IUrlSegmentRouter via IoC (subclassing DefaultUrlSegmentRouter). In our code, we sort the results from GetRoutingSegments so that the branch corresponding to the prefered language would come up top.
Please advice if this is the correct approach (we've not encountered anything weird so far, but who knows :).
And I've just noticed issue#90086 http://world.episerver.com/Support/Bug-list-beta/bug/90086/ in Patch 4 which sounds similar from the description. Can anyone confirm that the patch fixes this same issue?
How about hooking into the UrlRewriteProvider to one of the Convert to Internal events. And let the epslanguage query come from the cookie instead of the url segment?
Hello,
We're using EpiServer 7 Patch 3 and we're trying to use cookies instead of url designators (/en/ or ?epslanguage=en) to store visitors' language preference. We found that EpiServer's routing logic fails to take the language cookie into account when multiple versions of a page have the same url.
For example: page X is available in both en (English) and da (Danish) via the urls:
- en: /Test/
- da: /Test/
The URL http://domain/Test/ would always return English even when the cookie epslanguage is set to da.
Looking at the routing logics through a decompiler led me to believe that this line in ResolveContentForIncoming() from EPiServer.Web.Routing.Segments.DefaultUrlSegmentRouter
was responsible:
The call to GetRoutingSegments() returns all the language branches but it did not prioritize the list in any way. The subsequent call to FirstOrDefault() simply takes the first branch which might or might not match the visitor's current language.
We're working around this bug by injecting in our custom IUrlSegmentRouter via IoC (subclassing DefaultUrlSegmentRouter). In our code, we sort the results from GetRoutingSegments so that the branch corresponding to the prefered language would come up top.
Please advice if this is the correct approach (we've not encountered anything weird so far, but who knows :).
And I've just noticed issue#90086 http://world.episerver.com/Support/Bug-list-beta/bug/90086/ in Patch 4 which sounds similar from the description. Can anyone confirm that the patch fixes this same issue?