Dictionary value in ApiController not returning value
Hello folks!
I can't get the dictionary value in an api controller...
Setting the culture doesn't do the trick (either or both), and only an empty string is returned.
Thread.CurrentThread.CurrentCulture = new CultureInfo(model.Culture);
Thread.CurrentThread.CurrentUICulture = new CultureInfo(model.Culture);
var productSelectorPageId = Umbraco.GetDictionaryValue("productSelectorPageId");
I had similar issue with umbraco v6 site but I was doing some ajax with a surface controller. I fixed it by having a method that set the culture:
protected void SetCultureForAjax()
{
//we lose culture and dictionary wont get labels therefore set it on the thread
string code = _umbracoService.GetCultureCode();
//Get the culture info of the language code
CultureInfo culture = CultureInfo.CreateSpecificCulture(code);
Thread.CurrentThread.CurrentCulture = culture;
Thread.CurrentThread.CurrentUICulture = culture;
}
Although looking at your code you are doing a similar thing to me.
Dictionary value in ApiController not returning value
Hello folks!
I can't get the dictionary value in an api controller...
Setting the culture doesn't do the trick (either or both), and only an empty string is returned.
Any ideas, anyone?
Hi Ulf,
A few questions :
Dave
Hi Dave,
1/ sv-Se
2/ yes (in back office atleast)
3/ yes, the node id for the options to select
Hi Ulf,
Can you post some more code from your controller ?
Because we are using the same approach and that works for us.
Dave
Sorry, but no, there aren't any more code right now... (Except the method declaration and a try-catch.)
Hi Ulf,
Probably need the full code to see what's going on.
Dave
Hi Ulf,
Are you inheriting from UmbracoApiController ?
If so can you try this
Dave
Dave,
Yes, UmbracoApiController
I've tested both of these, and on a page they both return the value, but in the controller they also return an empty string...
Had to make a work-around in my code, so this is now for educational purposes.
Ulf,
I had similar issue with umbraco v6 site but I was doing some ajax with a surface controller. I fixed it by having a method that set the culture:
Although looking at your code you are doing a similar thing to me.
is working on a reply...