Charset problem between Asp.Net MVC with Entity Framework and SQL Server

Asked

Viewed 308 times

1

I’m having a problem that all the values that come from the bank SQL Server, are having accentuation problem.

When written words are directly on HTML, does not give this problem. What is strange is that the words are written correctly in the database, without any problem in accentuation, the problem is time to present on screen these values, example:

Exemplo

The right word would be Jose, and look how it’s in the database:

Exemplo

I’ve tried to define the globalization in the web.config, thus:

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

But it didn’t work.

EDIT:

The values are correct when loaded in the Controller, see the examples in Database, Controller and View:

Bench:

Banco

Controller:

Controller

View:

View

  • When you debug, within the class is the information correct? Post your view.

  • See if inside your <head> has the <meta charset="utf-8" />

  • @Marlontiedt I’m posting...

  • @Pablovargas as I said, the texts written in pure HTML are not with this problem, but the charset is set.

  • Put a break point on the bank return and see how it is returning.

  • @Marlontiedt post edited with the respective values...

  • @Pablovargas is in the main post....

  • Post the code of your View please.

  • @Bruno Already tried to add what Pablo added to the comments ?

  • @Bruno we need the View code and not what it shows, open the cshtml file copies and pastes the code in the question.

  • @Marconi.

  • @Bruno, take the entire view code...

Show 7 more comments

1 answer

0

This is wrong here:

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

The default ASP.NET MVC is the UTF-8 encoding. There is no reason to use ISO-8859-1, which is more limited.

Switch to:

<globalization culture="pt-BR" uiCulture="pt-BR" requestEncoding="UTF-8" responseEncoding="UTF-8" fileEncoding="UTF-8" />

Or even simply remove requestEncoding, responseEncoding and fileEncoding.

  • my case is similar. However, it is correcting one part and affecting the other that was already correct. Have any idea ?

Browser other questions tagged

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