Remove HTML formatting in Razor MVC 3

Viewed 18530

I am using MVC 3 and Razor View engine.

What I am trying to do

I am making a blog using MVC 3, I want to remove all HTML formatting tags like <p> <b> <i> etc..

For which I am using the following code. (it does work)

 @{
 post.PostContent = post.PostContent.Replace("<p>", " ");   
 post.PostContent = post.PostContent.Replace("</p>", " ");
 post.PostContent = post.PostContent.Replace("<b>", " ");
 post.PostContent = post.PostContent.Replace("</b>", " ");
 post.PostContent = post.PostContent.Replace("<i>", " ");
 post.PostContent = post.PostContent.Replace("</i>", " ");
 }

I feel that there definitely has to be a better way to do this. Can anyone please guide me on this.

3 Answers
Related