How Can I strip HTML from Text in .NET?

后端 未结 9 1827
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-12-16 02:20

I have an asp.net web page that has a TinyMCE box. Users can format text and send the HTML to be stored in a database.

On the server, I would like to take strip the h

9条回答
  •  情书的邮戳
    2020-12-16 03:03

    TextReader tr = new StreamReader(@"Filepath");
    string str = tr.ReadToEnd();     
    str= Regex.Replace(str,"<(.|\n)*?>", string.Empty);
    

    but you need to have a namespace referenced i.e:

    system.text.RegularExpressions
    

    only take this logic for your website

提交回复
热议问题