ASP.NET MVC: How to allow some HTML mark-up in Html Encoded content?

Posted by Dr. Zim on Stack Overflow See other posts from Stack Overflow or by Dr. Zim
Published on 2010-03-29T05:00:55Z Indexed on 2010/03/29 5:03 UTC
Read the original article Hit count: 447

Filed under:
|

Is there some magic existing code in MVC 2 to Html.Encode() strings and allow certain html markup, like paragraph marks and breaks? (coming from a Linq to SQL database field)

A horrible code example to achieve the effect:

Html.Encode(Model.fieldName).Replace("&lt;br /&gt;", "<br />")

What would be really nice is to overload something and pass to it an array (or object) full of allowed html tags.

© Stack Overflow or respective owner

Related posts about asp.net-mvc

Related posts about htmlencode