First, I want to point out that the right way to avoid XSS vulnerabilities is to correctly encode user input before embedding it in your page . For example, if you assign a text string to the Text Label property , you need to encode the value because the text property is displayed verbatim as HTML:
label.Text = HttpUtility.HtmlEncode(user.Name)
(Note: by "plain text" I mean text where the characters are of type <and have no special meaning.)
-, , . ( - ). !
, , , . , . , <asp:Label> :
Imports System.Web.UI
Imports System.Web.UI.WebControls.Adapters
Public Class LabelControlAdapter
Inherits WebControlAdapter
Protected Overrides Sub RenderContents(writer As HtmlTextWriter)
Dim label As Label = Me.Control
label.Text = "***" + label.Text + "***" ' TODO: Use your anti-XSS library
MyBase.RenderContents(writer)
End Sub
End Class
LabelControlAdapter, Me.Control - .
.browser App_Browsers, , :
<browsers>
<browser refID="Default">
<controlAdapters>
<adapter
controlType="System.Web.UI.WebControls.Label"
adapterType="TempVBWebApp.LabelControlAdapter, TempVBWebApp" />
</controlAdapters>
</browser>
</browsers>