Disable encoding of unicode characters in ASP.NET-MVC3

后端 未结 2 1568
别跟我提以往
别跟我提以往 2021-01-19 15:37

On my site every text is served as UTF-8.

Since nowadays every browser supports unicode characters, I would like to use them as-is.

The asp.net framework is

2条回答
  •  太阳男子
    2021-01-19 15:58

    I'm afraid that you cannot turn this encoding feature off. This "nice" feature is provided by the WebUtility.HtmlEncode and you cannot influence the encoding.

    However with starting .net 4.0 you can customize the encoding behavior, with creating a class that inherits from the HttpEncoder and configure it in the web.cofig HttpRuntimeSection.EncoderType. But you need to implement your own custom encoding logic.

    Luckily .net 4.5 ships with a new HttpEncoder which encodes the bad stuff (like

提交回复
热议问题