I set up cultures for my views and changed the culture in the controller, but I can’t find how to find out which culture I use in the controller, I am looking for something like:
public class HomeController : Controller { public async Task<IActionResult> Index() { // Something like the next line var requestCulture = GetRequestedCulture() return View(); } }
thank you for your help
The response was on the Request Object, here is the code:
public async Task<IActionResult> Index() { // Retrieves the requested culture var rqf = Request.HttpContext.Features.Get<IRequestCultureFeature>(); // Culture contains the information of the requested culture var culture = rqf.RequestCulture.Culture; return View(); }
JohnnysAce answer works. If you just need an easy way to get the current culture, this is done as always in .net:
CultureInfo uiCultureInfo = Thread.CurrentThread.CurrentUICulture; CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
IRequestCultureFeature (. JohnnyAces, - ), Startup.cs. Microsoft https://github.com/aspnet/Entropy/blob/dev/samples/Localization.StarterWeb/Startup.cs
Source: https://habr.com/ru/post/1664598/More articles:onLayout not starting in WebView - react-nativeWait for React to complete the update. - javascriptКаков полный список атрибутов, которые вы можете настроить для приложений AppCompat и каковы их значения по умолчанию? - androidHow safe is the front with reaction and reduction? - securityAdd defer or async attribute to dynamically generated script tags via javascript - javascripthow to start / stop python function from 10 to 12:30 - pythonemu8086 does not recognize my shortcuts - assembly"Error writing to file" during SDK 7.1 Installation on Windows 10 - c ++Custom validation fails on client side - javascriptUsing Code Iris with Intellij to create class diagrams - intellij-ideaAll Articles