How can I set a fixed culture in ASP.NET Core RC 2?
My Startup.cs
:
var options = new RequestLocalizationOptions
{
DefaultRequestCulture = new RequestCulture("pt-BR", "pt-BR"),
SupportedCultures = new[] { new CultureInfo("pt-BR") },
SupportedUICultures = new[] { new CultureInfo("pt-BR") }
};
options.RequestCultureProviders.Insert(0, new CustomRequestCultureProvider(async context => await Task.FromResult(new ProviderCultureResult("pt-BR", "pt-BR"))));
app.UseRequestLocalization(options);
Some requests are still getting en-US
Request Localization means that, for each request, the framework will try to use the localization preferred by the requester. What you want is to change the default culture of your application to always use your locale, no matter what the user has set in her client browser. For this you may use a small middleware.
In your Startup.cs file add the following at the very top:
And add your middleware, somewhere in your project: