asp.net MVC3 DefaultModelBinder error messages keys

后端 未结 1 1868
忘掉有多难
忘掉有多难 2021-01-19 06:06

There\'s a lot of question (and answer) here on stackoverflow and other site about translating the default error messages provided by the DefaultModelBinder, such as this on

相关标签:
1条回答
  • 2021-01-19 06:57

    When DefaultModelBinder.ResourceClassKey = "ResourceFileName"; is set in Application_Start method the DefaultModelBinder class uses other resource keys than defined in the resource file used by Asp.Net MVC.

    While disassembling DefaultModelBinder there is a method GetUserResourceString that reads from the custom resource file. This functions is only called twice with these messages keys:

    • PropertyValueRequired (A value is required.)
    • PropertyValueInvalid (The value '{0}' is not valid for {1}.)

    These are the only messages that could be set for DefaultModelBinder in MVC3.

    0 讨论(0)
提交回复
热议问题