解码锚标记字符串
本文关键字:字符串 解码 | 更新日期: 2023-09-27 18:10:36
我有一个从第三方API返回的字符串,它包含完全形成的锚标记(在大多数情况下)。html看起来是完全正确的。
我想解码这个和输出到MVC视图作为一个有效的锚标记,但是HTMLDecode似乎不转换锚标记成一个链接。
我只是像这样输出文本;
<p>@HttpUtility.HtmlDecode(Model.Description)</p>
但是文本出现时包含锚标记,像这样;
This is a test description. Check here - <a href="http://query.nytimes.com/gst/fullpage.html?res=9F0DE2D81E3CF936A25753C1A9669C8B63&sec=&spon=&pagewanted=all">New York Times</a> for more information
我期待太多的HtmlDecode?
使用@Html.Raw()
<p>@Html.Raw(Model.Description)</p>
http://msdn.microsoft.com/en-us/library/gg480740%28v=vs.118%29.aspx