You can protect your .Net web app by using Razor HTML and Javascript encodingRazor HTML and Javascript encoding In addition to this there is a quite cool library: .NET AntiXSS Library which is:
an encoding library which uses a safe list approach to encoding. It provides Html, XML, Url, Form, LDAP, CSS, JScript and VBScript encoding methods to allow you to avoid Cross Site Scripting attacks. This library is part of the Microsoft SDL tools.