Escape text for HTML

后端 未结 9 925
别那么骄傲
别那么骄傲 2020-11-28 04:50

How do i escape text for html use in C#? I want to do

sample=\"blah\"

and have

blah&l         


        
9条回答
  •  不知归路
    2020-11-28 05:37

    Didn't see this here

    System.Web.HttpUtility.JavaScriptStringEncode("Hello, this is Satan's Site")
    

    it was the only thing that worked (asp 4.0+) when dealing with html like this. The' gets rendered as ' (using htmldecode) in the html, causing it to fail:

    It's Allstars
    

提交回复
热议问题