Chaudhry Mohsin Ali Chaudhry Mohsin Ali - 1 year ago 75
C# Question

Special Characters turn to html code C#

In my web app, I am sending some strings from the server, and I am using them like this in my JS

var Texts = {
FillAllFieldsError: '@Texts.FillAllFieldsError',
PasswordChangeSuccess: '@Texts.PasswordChangeSuccess'

The strings which are coming from the server have some special characters like "Ø,Æ" etc.. They turn up into something with HTML code "forespørsel".

Does anybody know how to solve it? I am using utf-8 encoding

<meta charset="utf-8" />

Answer Source

Using @Html.Raw() is the correct approach.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download