I have a filter that sets CurrentUICulture of the current thread as a value pulled from a cookie
And I have a model that is being tested 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 to this point, so it pulls out the correct language for the error message
If I set a breakpoint on the validator above, I see that the thread has the wrong culture.
If I run the code further, it then hits the breakpoint on the filter, which changes the flow culture
How to make filter code run before model validation hits in
I tried both to decorate the controller action method with a filter attribute, and apply it globally, for example.
GlobalConfiguration.Configuration.Filters.Add(new LocalizationApiFilter());
it is a web api, not mvc, although the concepts are the same
?