Localized ASP.NET MVC 3 Validation Messages Work on My Computer, but Not on the Server

I use localized validation messages in the form of ASP.NET MVC 3. It correctly generates HTML as

<input class="inputlong" data-val="true" data-val-length="Das Feld &amp;quot;Adresse&amp;quot; muss eine Zeichenfolge mit einer maximalen L&amp;#228;nge von 100 sein." data-val-length-max="100" data-val-required="Das Feld &amp;quot;Adresse&amp;quot; ist erforderlich." id="Address" name="Address" type="text" value="" /> 

This works fine on my machine when I install CurrentThread in English, German or Italian CultureInfo.

But it doesn’t work on two other development machines and a Windows Server 2008 R2 test machine (same project, same setup: I even installed the ASP.NET MVC 3 Tools Packs update language), but I still receive only English verification 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 any settings or some missing builds on other computers that I don’t know about?

+6
source share
2 answers

You may need to install the .net framewok package. For example, on my machine, verification messages will not appear in German until I installed the German language pack .

Required attribute is not part of asp.net-mvc, but a more general DataAnnotations, so the language pack should help.

+8
source

This is “a few years later,” but I would like to give me 2 cents. I recently had the same problem, but with the current technology glass: VS 2015, MVC 5, .NET 4.6; we are developing at México, and there was mixed language support with some verification error messages (most in Spanish and some in English).

I found this SO answer, but this did not help my situation, because when I tried to install the .NET language pack, the installer threw me a “you have a later installed version” message and the installation stopped!

As I fixed this, I installed the MVC language pack with Nuget for our project: Microsoft.AspNet.Mvc.es (obviously, there are localized packages for all supported Microsoft languages: just replace .es with your own language, for example Microsoft.AspNet.Mvc.de for German). After that, our application showed all validation errors in Spanish without any additional configuration.

I hope this helps someone with the same problems.

0
source

Source: https://habr.com/ru/post/910354/


All Articles