Special characters in html output

前端 未结 3 831
既然无缘
既然无缘 2021-01-03 10:52

I want characters like \'ø\' to be printed directly, but in the source \'ø\' shows up as ø

If the output goes through Html.Encode()

3条回答
  •  星月不相逢
    2021-01-03 11:04

    This might not be the answer you are looking for but it is nevertheless interesting.

    If you look at the HttpEncoder source code it makes provision for custom HtmlEncoders to be used instead of the default WebUtility.HtmlEncode

    I have played around and found the HtmlEncoder called AntiXSS from Microsoft encodes these characters correctly.

    I installed it using Nuget:

    PM> Install-Package AntiXSS 
    

    And then updated my web.config as such:

    
        
        ....
    
    

    Both normal output and Html.ActionLinks seem to work.

提交回复
热议问题