简体   繁体   中英

Non ASCII character in ASP.NET MVC 2

I have a MVC 2 application. <globalization requestEncoding="utf-8" responseEncoding="utf-8"/> is added in web.config and <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/> in master page. But the Non-ASCII characters still can not be encoded and decoded correctly.

For example, "Mayagüez" is displayed in an action, but after passed through a url, it is displayed as "Mayag ez".

If I try to use HttpUtility.HtmlEncode for "Mayagüez", the string is truncated as "Mayag" after processed through HttpUtility.HtmlDecode.

刚发现使用Url.Encode而不是HttpUtility.HtmlEncode可以使其工作。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM