This approach is not identical to StackExchange, but I found the AntiXSS 4.x library in an easy way to sanitize input to provide “safe” HTML.
http://www.microsoft.com/en-us/download/details.aspx?id=28589 , DOCX. - NuGet AntiXSS.
HtmlSanitizationLibrary, 4.x AntiXss. , GetSafeHtml() HtmlSanitizationLibrary Microsoft.Security.Application.Sanitizer.
content = Sanitizer.GetSafeHtml(userInput);
. , . , - , , .
, .
, .