Brian Crist
Brian Crist

Reputation: 814

How to remove html tag of meta tag in view MVC?

I have meta tag and it contain html tag. I want to remove this. Example content as :

<p><b>This is red color</b><br>

This is snipped code in view MVC

<meta name="description" content="@Model.description" />

Parameter @Model.description contain content text.

Upvotes: 0

Views: 1967

Answers (1)

Basanta Matia
Basanta Matia

Reputation: 1562

You can use regex to replace your html tags. For example,

string myContent = Regex.Replace(description, @"<(.|\n)*?>", string.Empty);

Or-else you can use WebUtility.HtmlDecode for .Net 4.0+ and for older version HttpUtility.HtmlDecode.

Hope it helps :)

Upvotes: 2

Related Questions