• Локализация ASP.NET MVC 4 DataAnnotations сообщений валидации в модели?

    @NORD75 Автор вопроса
    Спасибо за наводку на второй вариант. Внимательно прочитав, стало понятно, что у меня всё дело в неверной последовательности событий. Локализация задается слишком поздно.

    image

    Из статьи:

    «Let's explain one by one.

    For the first one, the localization didn't work at all. That is because we implemented the localization by the action filter attribute we created before. But the validation logic was performed by the default model binder which was invoked before the action filter attribute was performed. So when the model binder failed the validation and attempted to retrieve the error message from the resource files the culture of the current thread has not been changed by the action filter.

    In order to make the localization (culture setting) being invokde before the model binder was executed we should move the localization logic to the Controller.ExecuteCode method, which is earlier than the model binder and validation. So I created a new class named BaseController and let it inherited from the abstract Controller class and then overrided the ExecuteCode method with the localization logic. Then I updated all controllers in the application to inherit from this BaseController.»

    Ещё раз большое спасибо за помощь! Тема закрыта.
  • Локализация ASP.NET MVC 4 DataAnnotations сообщений валидации в модели?

    @NORD75 Автор вопроса
    Спасибо. Как я и думал провайдер ресурсов =(