Wednesday, March 14, 2012

SharePoint 2010 / MSOCAF - Use the Anti-XSS library to properly encode the data before rendering it

If you have the following error:
Use the Anti-XSS library to properly encode the data before rendering it

You will need to visit the Microsoft Download Center and download and install, at least, AntiXSS Library v4.2, from http://www.microsoft.com/download/en/details.aspx?displaylang=en&id=28589.
In your solution, you will need to add the reference, for AntiXSSLibrary, located wherever it was installed, in my system, at "C:\Program Files (x86)\Microsoft Information Security\AntiXSS Library v4.2\NET35\AntiXSSLibrary.dll".
using Microsoft.Security.Application;

// AntiXSS.HtmlEncode, has been recently deprecated. 
string strProperty = Encoder.HtmlEncode(Request["Property"]);