I've read through lots of postings on SO regarding XSS and how to deal. Generally, the consensus is whitelist over blacklist and avoid using Regular Expressions (too many variants to deal with).
I'm working on an ASP.Net MVC3 application. I need to be able to display HTML from the user entry (ex. < strong >, < ul >, < li >, etc...) but I don't want any XSS risks.
I'm using the AntiXSS package via Nuget. In my model, I have
[AllowHtml]
public string UserDetails{ get; set; }
In my view, I have TinyMCE hooked into the textarea.
In my controller, I get the post from the View and sanitize it:
using Microsoft.Security.Application;
...
string SanitizedDetails = Sanitizer.GetSafeHtmlFragment(model.UserDetails);
My question: Did I do it right? Am I protected from most XSS issues or am I barking up the wrong tree?