使用 rss feed(syndicationfeed) 我有一些编码文本,通常在视图中我可以说 @Html.Raw(feed.summary) 其中 feed.summary 是一些带有文本的 html,它会显示没有所有文本的文本html代码。但是由于某种原因,这不起作用。它打破了我的看法,没有崩溃,只是没有显示任何东西。所以我想知道是否有一种方法可以在代码中执行此操作,这样文本将全部准备好,并且在我看来我不必使用 Html.Raw() 。任何建议表示赞赏。
@Html.Raw(feed.RssShortSummary)
//This doesn't work, it messes all my styling up and simply doesn't even display the text.
在后面的代码中:(我尝试过 MvcHtmlString.Create())但仍然返回 html 代码,而不是我需要的文本。
MvcHtmlString.Create(summary);
所以如果我有:
<p>Here is some text</p>
Html.Raw() 将返回“Here is some text”,但由于某种原因这会扰乱我的观点。我已经尝试过 MvcHtmlString.Create 但它仍然返回给我:
<p>Here is some text</p> //returning all the html instead just "Here is some text"
在代码c#中我试过:
var x = MvcHtmlString.Create(rssItem.RssSummary);
例如 rssItem.RssSummary =
<p>Here is some text</p>
x 仍在生成:
<p>Here is some text</p>