Problem with ASP.NET MVC3 razor with international characters in custom html helpers

I'm currently trying to convert an ASP.NET MVC2 application to an ASP.NET MVC3 razor. I have many custom Html helper methods that output html output, as shown below, which displays a button with some markup:

StringBuilder sb = new StringBuilder("<input type='submit' id='")
            .Append(buttonId)
            .Append("' name='" )
            .Append(buttonId)
            .Append("' value='")
            .Append(buttonValue)
            .AppendLine("' class='myclass1 myclass2' />");
return MvcHtmlString.Create(sb.ToString());

When buttonValue contains international characters, such as é or ë, the button text becomes erroneous, I assume that some kind of encoding is happening ...

Eg. ë changes to "

I know MVC3 uses some kind of template system for its html helpers, but since I have a lot of my own helpers, it will take a long time to find out about this and change all my current user helpers.

+3
1

, -, cshtml, #, . cshtml, , cshtml aspx ascx . ,

File.WriteAllText(filename,text) 

to

File.WriteAllText(filename, text,Encoding.Default)
0

Source: https://habr.com/ru/post/1775042/


All Articles