I have a filter that sets the CurrentUICulture of the current thread to be a value pulled from a cookie
And I have a model that is being validated using the FluentValidation library
[Validator(typeof(MyInputModelValidator))]
public class MyInputModel
public class MyInputModelValidator: AbstractValidator<MyInputModel>
{
public MyInputModelValidator()
{
var x = Thread.CurrentThread.CurrentUICulture.Name;
RuleFor(o => o.Country).NotEmpty().WithMessage(Resources.NoCountryError);
I want the thread culture to be changed by this point so it pulls the correct language for the error message
If I put a break point on the validator above I can see the thread has the wrong culture.
If I run the code further, it then hits a break point on the filter which changes the culture of the thread
How can I make the filter code run before the model validation kicks in
I have tried both decorating the controller action method with the filter attribute and applying it globally e.g.
GlobalConfiguration.Configuration.Filters.Add(new LocalizationApiFilter());
this is web api, not mvc , though the concepts are the same
any ideas?