ASP.NET MVC 3 本地化验证消息在我的机器上有效,但在服务器上无效 [英] ASP.NET MVC 3 localized validation messages work on my machine, but not on server
问题描述
我在 ASP.NET MVC 3 表单中使用本地化验证消息.它正确地生成 HTML 像
I'm using localized validation messages in a ASP.NET MVC 3 form. It correctly generates HTML like
<input class="inputlong" data-val="true"
data-val-length="Das Feld &quot;Adresse&quot; muss eine Zeichenfolge mit
einer maximalen L&#228;nge von 100 sein."
data-val-length-max="100"
data-val-required="Das Feld &quot;Adresse&quot; ist erforderlich."
id="Address" name="Address" type="text" value=""
/>
当我将 CurrentThread 设置为英语、德语或意大利语 CultureInfo 时,在我的机器上可以正常工作.
This works fine on my machine when I set my CurrentThread to an English, German or Italian CultureInfo.
但它在其他两台开发人员机器和一台 Windows Server 2008 R2 测试机器上不起作用(相同的项目,相同的设置:我什至安装了 ASP.NET MVC 3 Tools Update Language包),但我仍然只收到英文验证消息:
But it doesn't work on two other developer machines and a Windows Server 2008 R2 test machine (same project, same setup: I've even installed the ASP.NET MVC 3 Tools Update Language Packs), but I still get only the English validation messages:
<input class="inputnormal input-validation-error" data-val="true"
data-val-length="The field Adresse must be a string with a maximum length of 100."
data-val-length-max="100" data-val-required="The Adresse field is required."
id="Address" name="Adresse" type="text" value=""
/>
我不知道的其他计算机上是否有设置或缺少某些程序集?
Are there settings or some missing assemblies on the other computers I am not aware of?
推荐答案
您可能需要安装 .net framewok 语言包.例如,在我安装 德语语言包一个>.
You may have to install .net framewok language pack. For example, on my machine validation messages would not show up in German until I installed German language pack.
Required
属性不是 asp.net-mvc 的一部分,而是更通用的 DataAnnotations,因此语言包应该有所帮助.
Required
attribute is not part of asp.net-mvc but more general DataAnnotations, so language pack should help.
这篇关于ASP.NET MVC 3 本地化验证消息在我的机器上有效,但在服务器上无效的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!