Microsoft Anti-Cross Site Scripting Library V4.0
AntiXSS is an open source .NET assembly available for download from Microsoft (source here). This library provides much more flexible XSS protection in .NET applications than the built-in Server.HTMLEncode() approach, as it adds support for XML and LDAP filter encoding in addition to HTML encoding. By allowing flexible and secure encoding and decoding of strings for these types of data, application developers can breathe a little easier when accepting data across trust boundaries.
Libraries such as AntiXSS that perform string processing are incredibly useful for developers, for several reasons. First, they are maintained separately from your code base, so any updates to the string processing functions for emerging threats can be applied without much hassle. Second, by using a code library with a wide user base and is regularly maintained with updates from the developers, the risk of a security hole from a bad implementation is much lower. Finally, it’s free – and your time developing custom string processing code is not!