Vulnerability in EPiServer.Forms
On the site were working on we use multiple auto suggestion fields. I implemented it as described in http://world.episerver.com/blogs/Linus-Ekstrom/Dates/2014/7/Built-in-auto-suggestion-editor/. It works except when i change the locale in episerver cms, ContentLanguage.PreferredCulture gives me the language of the host and not the one I selected. Code:
public class AMPromotionSelectionQuery : ISelectionQuery
private IPromotionService _promotionService;
public AMPromotionSelectionQuery(IPromotionService promotionService)
_promotionService = promotionService;
_items = _promotionService.GetActionModulePromosForCms(ContentLanguage.PreferredCulture.TwoLetterISOLanguageName)
.Select(x => new SelectItem()
Text = x.Name,
Value = x.Id
}).OrderBy(x => x.Text)
//Will be called when the editor types something in the selection editor.
public IEnumerable GetItems(string query)
return _items.Where(i => i.Text.StartsWith(query,StringComparison.InvariantCultureIgnoreCase));
//Will be called when initializing an editor with an existing value to get the corresponding text representation.
public ISelectItem GetItemByValue(string value)
return _items.FirstOrDefault(i => i.Value.Equals(value));
So when calling ContentLanguage.PreferredCulture.TwoLetterISOLanguageName I get "nl" back, but the content language selected is "de". What can I do to fix this?
Another way to fix this is to change hosts when selecting a language. Is there a way to do that? So I have 3 hosts configured. 1 for en, 1 for de and one for nl. when im on http://site.nl/episerver and click one of the following:http://screencloud.net/v/m4va
Is it possible to go to http://site.de/episerver?
As you mention, the cause of the problem is that the URL to the suggestion service does not append language information. If you register specific URL:s for each language (under Manager Website Languages) I hope that this will work, though I have tried this yet. Have you done to Niels and if so, does it solve it?
Hi, thanks for your response.
Could not find a field where i can do that. In this image you can see my configuration.
As you can see in the bottom part is that on the manage website languages there is no option to configure a url.
Hmm, that sounds like the correct set up. Could you see what the URL is to the selection Service when you are on a second language getting the failure? For instance, my URL looks like this in a development environment:
It this still an issue or have you solved it? If not, is *.nl mapped to Dutch and is this what you are getting in the service or is it falling back to another language?
No its not solved yet. .nl is mapped to dutch in the host table under website settings as seen in http://snag.gy/qKkXX.jpg. And I am seeing the correct language. Also when changing the language under the page settings or under CMS->Edit->Sites the correct language is shown. The problem is really in the auto suggestion ajax call. Cause when changing the language the host does not change, only the url query parameters. For example:http://local.*****.nl/EPiServer/CMS/?language=de#context=epi.cms.contentdata:///5
And in the ajax call it still thinks its dutch, even though it should be german.
I think I've found what's missing and a temporary work around. If you browse directly to the UI for the URL that's mapped to the language, content language will follow the UI. However, if you use the site switcher to switch language the URL will not be changed. Instead, a header value is passed into the requests by our REST store on the client. This is however not done for the auto suggestion editors which are using the default Dojo REST store. I've registered a bug for this and hopefully, it should be pretty easy to fix:
Bug #122418: Auto Suggestion editors does not handle content language
Ok thanls :)
This bug has now been fixed and will be released within a few weeks.
Ok nice :). Thanks alot!