Dataannotation validation displaying message in English

Asked

Viewed 313 times

0

Good afternoon,

In my system I made the validations with date Annotations, locally the messages are displayed in Portuguese, when I publish the text message on the host server is displayed in English, anyone know how to keep in Portuguese? From now on I graduate

  • Windows server is in English?

  • Related: https://answall.com/questions/335376/razor-linguagem-regionalidade/335381#335381

  • this example refers to date and also to . net core, I am using Asp.net MVC

  • Other related: https://answall.com/questions/137931/como-usar-recursos-em-portugu%C3%Aas-br-de-microsoft-Asp-net-mvc

1 answer

1


This happens by simply answering, because the configuration of your local IIS is in Portuguese and your remote IIS is in English.

To change this globalization setting of your IIS you must add the following line in your file web config..

<configuration>
    <system.web>
        <globalization culture="pt-BR" uiCulture="pt-BR"/>
    </system.web>
</configuration>
  • I already have this line on my web.config, it’s like this: <globalization Culture="en-BR" fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" uiCulture="en" />

  • Adds enableClientBasedCulture="false" property, tests with true as well.

  • Nothing, already tested with the 2. continue displaying in English

  • Guy sends a snippet of the date Annotation

  • I’m validating with [Stringlength(20)]

  • and the error is returned: Error The field Fieldname must be a string with a Maximum length of 20.

  • face passes the second parameter, which is the error message: [Stringlength(20, Errormessage="Error message")], just to see what the output will be.

  • Thanks, so it worked out. Thanks

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.