Using a rss feed(syndicationfeed) I have some encoded text where normally in the view I can just say @Html.Raw(feed.summary) where feed.summary is some html with text in it, and it will display the text without all the html code. However for some reason, this is not working. It’s breaking my view, no crashing its just not displaying anything. So I was wondering if there is a way to do this in code behind that way the text will all ready be stipped and I don’t have to use Html.Raw() in my view. Any advice is appreciated.
@Html.Raw(feed.RssShortSummary)
//This doesn't work, it messes all my styling up and simply doesn't even display the text.
In Code behind: (I’ve tried MvcHtmlString.Create()) but still returns the html code and not the text I need from it.
MvcHtmlString.Create(summary);
So if I have:
<p>Here is some text</p>
Html.Raw() will return “Here is some text” but this messes my view for some reason. I’ve tried MvcHtmlString.Create but it is still returning to me:
<p>Here is some text</p> //returning all the html instead just "Here is some text"
In code c# I tried:
var x = MvcHtmlString.Create(rssItem.RssSummary);
where for example rssItem.RssSummary =
<p>Here is some text</p>
x is still generating:
<p>Here is some text</p>
There are many approaches for removing tags in .net, C# Remove HTML Tags nice article in which described several approaches for removing tags, based on that article, the best approach to remove tags is StripTagsCharArray because it more faster than Regex approaches: