Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • John 2 posts 72 karma points
    Aug 07, 2019 @ 11:30
    John
    0

    Getting a culture specific content URL from SurfaceController or WebApi

    I have a site set up with multiple cultures and host-names at the root, eg.

    http://mysite.com/uk
    http://mysite.com/us
    http://mysite.com/au

    if i browse to http://mysite.com/us/products, in the razor view I can then get a list of product nodes, all with the correct culture-specific URLs. eg.

    productsNode.DescendantsOfType("product").ToList();
    

    each one has the correct URL for the page culture, eg:
    http://mysite.com/us/products/product-1

    However, if I want to implement a product-search feature, which uses jquery to call a SurfaceController action to return a list of products in a partial view, the SurfaceController has no concept of the current culture, so I get a list of products all with URLs set as (i think) the first domain/culture that umbraco can find (UK in this case)

    eg.
    http://mysite.com/uk/products/product-1

    How can I tell umbraco to give me a content URL specific to a certain culture (in this case, I'd want it to be the culture of the page that is making the ajax/surface request)?

    This seems like a pretty common scenario; anybody using culture url's who is making SurfaceController or WebApi requests for content items will face this problem, but I can't find any documentation on it

Please Sign in or register to post replies

Write your reply to:

Draft