Search code examples
c#model-view-controllerasp.net-core-6.0

Can not display specific character from model in Class Library ASP.NET Core MVC


I have an ASP.NET Core MVC application which have the hierarchy like this:

enter image description here

Inside the CustomerModel.cs file, I have a field that I want to bind to a text box for input:

[Required(ErrorMessage = "Le nom de la société est obligatoire")]
[Display(Name = "Raison sociale")]
public string Company { get; set; }

What I have done in view:

@Html.TextBoxFor(m => m.Company, new { @class = "input" })
@Html.ValidationMessageFor(m => m.Company, "", new { @class="has-text-danger" })

The problem is: Title and validation message are rendered correctly in development mode, but when I deploy the application to Azure, some specific character in the title and validation message is not rendered correctly. In this case the character é.

enter image description here

I have already used <meta charset="utf-8" /> in my _Layout.cshtml but it still doesn't work.

Does anyone have an idea what causes the problem and how to fix it?

Thank you!


Solution

  • I got same problem with file encoding. Check file encoding for CustomerModel.cs, it must be utf-8 too. I used notepad++ for this.