C# QueryStringRequestCultureProvider localization doesn't work

Viewed 539

I have setup localization in my ASP.Net Core Web API project following this documentation: docs.

When I change the default request culture in my Startup.cs:

services.Configure<RequestLocalizationOptions>(options =>
{
     options.DefaultRequestCulture = new RequestCulture("en-US");
     options.SupportedCultures = new List<CultureInfo> { new CultureInfo("en-US"), new CultureInfo("bs-Latn-BA") };
     options.RequestCultureProviders = new List<IRequestCultureProvider>()
     {
         new QueryStringRequestCultureProvider()
     };
});

to, for example, bs-Latn-BA, resources are read from the correct .resx file and everything works as expected.

However, when I try to change the culture in a request, for example: https://localhost:44386/api/v0.1/login?culture=bs-Latn-BA, the default version of the string is returned.

0 Answers
Related