How to solve accent problems with ASP.NET MVC?

Asked

Viewed 17,754 times

15

I’m having problems with accentuation in ASP.NET MVC 5.

I am using Visual Studio 2013 Professional and in the application . Net 4.5. SQL Server 2008 and Entity Framework 6. The browser is Google Chrome updated and Windows is 8.1.

Example:

Where I want you to appear "Endereço" is appearing "Endereço".

inserir a descrição da imagem aqui

How can I fix this?

  • 3

    This is a character encoding problem. What encoding are you using on the page or website?

  • On the page I’m putting lang en-br, charset utf-8.

  • 2

    I decided to add the tag on the web.config: <globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="pt-br"/>, within the section <system.web>. Grateful!

  • Use this encoding: "iso-8859-1" which is English

5 answers

17


As I mentioned in the comments on this question, I solved the problem by adding this tag to my web.config file:

<globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-8" culture="pt-br"/>

Stayed like this:

inserir a descrição da imagem aqui

There’s another thing I found that can also affect character recognition, which is the file format.

I had problems with character recognition again after the implementation of this tag on the project’s web.config.

This time it was only on a few pages where the word "Descrição"appeared as "Descri??o".

I tried some modifications, like putting Encode in the tag with "iso-8859-1". This only worsened the situation as Bootstrap is not compatible and the previous problem had returned.

So I decided to see the format of the files cshtml And I found that in these pages that were giving this problem the Ncode was as ANSI. If you open the file with the note pad, for example, and ask "Save As", the window to choose the file and destination location shows the current file encounter. So all I did was change to utf-8 and save. And then these pages returned to display the characters correctly.

How did I change the pattern of these files to ANSI? I don’t know!

But anyway, problem solved again.

4

I decided to put in the web.config:

<system.web>
    <globalization
         fileEncoding="iso-8859-1"
         requestEncoding="iso-8859-1"
         responseEncoding="iso-8859-1"
         culture="pt-BR"
         uiCulture="pt-BR"
    />
</system.web>

2

Check your configuration file ( WEB.CONFIG ). Add the tag below inside system.web, should work.

<globalization fileEncoding="utf-8" requestEncoding="utf-8" responseEncoding="utf-
8" culture="pt-br"/>

1

In my case I modified the encoding of the saved file.

I did the next step in VS

Menu "File"-> "Advanced Save Options" and I selected "Unicode(UTF-8 with Signature)-Codepage 65001"

Using Asp.net Core

Worked.

0

I have the solution to your problem, follow the following steps:
1. Open the file containing accentuated words;
2. Go to the File->Save As;
3. And there press the little arrow button Save and, Save with Encoding.
4. Then choose the UTF-8 option.
5. Don’t worry if VS asks you to replace the file.

Start the project and see.

Browser other questions tagged

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