Microsoft just released the beta version of a Visual Studio Add-In that would scan your code in order to detect the potential issue that can make your code vulnerable to "Cross-Site scripting" attacks.
Check out the tool here
Check out some background information and tips here to learn how to write code to avoid such attacks.