有时候我们在解析一段文字时,可能文字中会包含网页上的标签,如div、p等等。那么如果将这种文字渲染成对应的标签效果呢?如图,最近博主就拿到了这么一段字符串(如图)
由于中间带有很多特殊字符,用Html.Raw()方法渲染后,却未出现预期结果(如图)
经过一番资料查找,得知,这种字符串需要用Http.HtmlDecode()将字符串进行编码,得到正确的html字符串之后,再用Html.Raw()来渲染就OK了(如图)。
问题解决~(如果看不清图片,可以将图片直接拖拽到浏览器新标签中打开)