C# 如何仅从控制器内部的html内容中获取文本?

C# 如何仅从控制器内部的html内容中获取文本?,c#,asp.net,asp.net-mvc,C#,Asp.net,Asp.net Mvc,我有这样的想法: using (var context = new MyDb()) { var post = context.Posts.Where(p => p.ThreadId == item).OrderBy(p => p.DateCreated).First(); ViewBag.Description = post.Conent; //post.Content contains content of the post; that means html + use

我有这样的想法:

using (var context = new MyDb())
{
   var post = context.Posts.Where(p => p.ThreadId == item).OrderBy(p => p.DateCreated).First();
   ViewBag.Description = post.Conent; //post.Content contains content of the post; that means html + user text
}

当前我的
ViewBag.Description
包含
post.Content
中的所有内容,我需要它只包含文本。如何操作?

使用此函数从字符串中删除HTML标记:

public string StripHtml(string text)
{
    return Regex.Replace(text, "<(.|\\n)*?>", string.Empty);
}
公共字符串StripHtml(字符串文本)
{
返回Regex.Replace(text,“,string.Empty);
}

可能重复使用Regex删除html标记