Grab ID or Name of Selected Language within Razor

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
11 лет назад
Hi guys

So basically as the title of the thread suggests. All I want to know is how I can check what Language is currently selected for the store, so that I can use it in an if statement to display whatever I want based on the selected language.

I would greatly appreciate any help.

Thank You.

Ciwan.
11 лет назад
Add the Language field to your Model and set it with IWorkContext.WorkingLanguage
11 лет назад
Thanks Andy.

When I do, WorkContext returns null ! Here is my code:

public partial class HomeController : BaseNopController
    {
        private readonly IWorkContext _workContext;

        [NopHttpsRequirement(SslRequirement.No)]
        public ActionResult Index()
        {
            var x = _workContext.WorkingLanguage.Id;
            ViewBag.ActiveLanguageId = x;
            return View();
        }
    }
11 лет назад
You need to add it as a dependency in your constructor, similar to services or settings.
11 лет назад
Thank You Andy, that did it :)
This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.