AntiXssEncoder 类

定义

对用于 HTML、XML、CSS 和 URL 字符串的字符串进行编码。

public ref class AntiXssEncoder : System::Web::Util::HttpEncoder
public class AntiXssEncoder : System.Web.Util.HttpEncoder
type AntiXssEncoder = class
    inherit HttpEncoder
Public Class AntiXssEncoder
Inherits HttpEncoder
继承
AntiXssEncoder

注解

可以使用 AntiXssEncoder 该类替代 HttpEncoder 默认情况下用于在类的方法(例如 HttpUtilityHttpServerUtilityHttpResponseHeader)中对字符串进行编码和解码的类。

AntiXssEncoder 类中,在安全列表中找不到的所有字符都由 HtmlAttributeEncodeHtmlEncode 方法进行编码。

若要将HttpEncoder类替换为该类,请使用 AntiXssEncoder Web.config 文件中 httpRuntime 元素的属性注册该类encoderType,如以下示例所示:

<httpRuntime encoderType="System.Web.Security.AntiXss.AntiXssEncoder" />

可以在注释HtmlAttributeEncodeHtmlEncodeXmlAttributeEncodeXmlEncode中找到不同编码方法的默认安全字符列表和方法。 可以使用该方法 MarkAsSafe 修改默认安全列表。

构造函数

名称 说明
AntiXssEncoder()

初始化 AntiXssEncoder 类的新实例。

方法

名称 说明
CssEncode(String)

编码在级联样式表(CSS)中使用的指定字符串。

Equals(Object)

确定指定的对象是否等于当前对象。

(继承自 Object)
GetHashCode()

用作默认哈希函数。

(继承自 Object)
GetType()

获取当前实例的 Type

(继承自 Object)
HeaderNameValueEncode(String, String, String, String)

将标头名称和值编码为可用作 HTTP 标头的字符串。

(继承自 HttpEncoder)
HtmlAttributeEncode(String, TextWriter)

编码并输出在 HTML 属性中使用的指定字符串。

HtmlDecode(String, TextWriter)

从 HTML 编码的字符串解码值。

(继承自 HttpEncoder)
HtmlEncode(String, Boolean)

将指定字符串编码为 HTML 标记中的文本,并选择性地指定是否使用 HTML 4.0 命名实体。

HtmlEncode(String, TextWriter)

对指定字符串进行编码,以便在 HTML 标记中用作文本,并使用指定的文本编写器输出字符串。

HtmlFormUrlEncode(String, Encoding)

使用指定的字符编码类型对 MIME 类型为“application/x-www-form-urlencoded”的表单提交编码指定的字符串。

HtmlFormUrlEncode(String, Int32)

使用指定的代码页对 MIME 类型为“application/x-www-form-urlencoded”的表单提交中要使用的指定字符串进行编码。

HtmlFormUrlEncode(String)

编码在 MIME 类型为“application/x-www-form-urlencoded”的表单提交中使用的指定字符串。

JavaScriptStringEncode(String)

对字符串进行编码。

(继承自 HttpEncoder)
MarkAsSafe(LowerCodeCharts, LowerMidCodeCharts, MidCodeCharts, UpperMidCodeCharts, UpperCodeCharts)

将指定 Unicode 代码图表中的字符标记为安全。

MemberwiseClone()

创建当前 Object的浅表副本。

(继承自 Object)
ToString()

返回一个表示当前对象的字符串。

(继承自 Object)
UrlEncode(Byte[], Int32, Int32)

对指定的字节数组进行编码,以便在 URL 中使用,从字节数组中的指定偏移量开始,并编码指定的字节数。

UrlEncode(String, Encoding)

使用指定的字符编码类型对 URL 中使用的指定字符串进行编码。

UrlEncode(String, Int32)

使用指定的代码页对在 URL 中使用的指定字符串进行编码。

UrlEncode(String)

对指定字符串进行编码,以便在 URL 中使用。

UrlPathEncode(String)

对要在 URL 中使用的路径字符串进行编码。

XmlAttributeEncode(String)

对指定字符串进行编码,以便在 XML 属性中使用。

XmlEncode(String)

对指定字符串进行编码,以便在 XML 属性中使用。

适用于