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

    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.

    if i browse to, in the razor view I can then get a list of product nodes, all with the correct culture-specific URLs. eg.


    each one has the correct URL for the page culture, eg:

    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)


    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

  • Sven 33 posts 136 karma points
    Apr 24, 2020 @ 06:36

    Hello there,

    Did you find any solution to this ?

    Thank you!

  • andrew shearer 483 posts 606 karma points
    May 18, 2020 @ 00:42
    andrew shearer

    yes - would like to know best practice here too :)

  • Asembli 53 posts 173 karma points
    May 19, 2020 @ 11:01

    Hi, you can always send current lang from document template to surface controller:

        // in document template razor
    string currentLang = Model.Content.GetCulture().TwoLetterISOLanguageName;
        // call to surface controller
    Url.Action("DoSomething", "MySurface", new { lang = currentLang })
    // surface controller
    public ActionResult DoSomething(string lang)
        // set culture
        Thread.CurrentThread.CurrentCulture = new System.Globalization.CultureInfo(lang);
        // call partial view with the same culture as in document template
        return PartialView("~/Views/Partials/SomePartial.cshtml", model);


Please Sign in or register to post replies

Write your reply to: