Skip to content

Instantly share code, notes, and snippets.

@shawndumas
Created September 16, 2011 12:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shawndumas/1222031 to your computer and use it in GitHub Desktop.
Save shawndumas/1222031 to your computer and use it in GitHub Desktop.
(Partial) XSS Fix For ASP.NET
' In the web.config
'
'<pages>
' <tagMapping>
' <clear />
' <add tagType="System.Web.UI.WebControls.TextBox"
' mappedTagType="XSSTextBox"/>
' </tagMapping>
'</pages>
Imports Microsoft.Security.Application.Sanitizer
Public Class XSSTextBox
Inherits TextBox
Public Overrides Property Text() As String
Get
Return GetSafeHtmlFragment(MyBase.Text)
End Get
Set(ByVal value As String)
MyBase.Text = value
End Set
End Property
End Class
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment