Culture specific Url from IPublishedContent node in web api
Hi All, I have a site with multiple domains for various languages, set in Culture and Hostnames under the Home node. In a web api, I would like to return the Url of a node, but with the link that is specific to the current language (ie the current domain). Using @item.Url in razor works fine - however from the web api the value returned is not specific to the current culture/domain. It seems to be returning a value consistent with the first item in the list of 'Link to Document' items under the Properties tab of the node - but perhaps just a coincidence. Does anyone know how to return the correct Url? Thanks, Steve
Hi Peter, Yes, it seems like the culture settings are not available from within the web api. For anyone interested, I generated a functional url by building a string in the api using something similar to: item.parent.name + "/" + item.name and then getting the current culture in the view and passing that as razor variable into the javascript api .success function where the html is created. Steve
Culture specific Url from IPublishedContent node in web api
Hi All,
I have a site with multiple domains for various languages, set in Culture and Hostnames under the Home node. In a web api, I would like to return the Url of a node, but with the link that is specific to the current language (ie the current domain). Using @item.Url in razor works fine - however from the web api the value returned is not specific to the current culture/domain. It seems to be returning a value consistent with the first item in the list of 'Link to Document' items under the Properties tab of the node - but perhaps just a coincidence.
Does anyone know how to return the correct Url?
Thanks, Steve
Hi Steve,
In Razor UmbracoContext.Current.PublishedContentRequest.Culture is set to the Culture of the current node you view.
I think this is missing when a Web Api request is made, it is worth try setting UmbracoContext.Current.PublishedContentRequest.
How to do that however, unfortunately I'm not aware of, it seems you need to get an Umbraco.Web.Routing.RoutingContext which has internal constructor.
Regards, Peter
Hi Peter,
Yes, it seems like the culture settings are not available from within the web api.
For anyone interested, I generated a functional url by building a string in the api using something similar to: item.parent.name + "/" + item.name and then getting the current culture in the view and passing that as razor variable into the javascript api .success function where the html is created.
Steve
is working on a reply...