語言

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 預設用於編碼和解碼類別方法中字串的類別,例如 HttpUtility、 HttpServerUtility、 HttpResponseHeader。

在類別AntiXssEncoder中,所有不在安全清單中的字元都由 and HtmlAttributeEncode 方法編碼HtmlEncode。

要將類別替換 HttpEncoder 為 AntiXssEncoder 類別,請使用 encoderType Web.config 檔案中 httpRuntime 元素的屬性註冊,如下範例所示:

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

不同編碼方法的預設安全字元列表可在 、 HtmlAttributeEncode、 HtmlEncode及 XmlAttributeEncode 方法的備註XmlEncode中找到。 預設安全清單可透過此 MarkAsSafe 方法進行修改。

建構函式

名稱 Description
AntiXssEncoder()

初始化 AntiXssEncoder 類別的新執行個體。

方法

名稱 Description
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)

編碼用於網址的路徑字串。

XmlAttributeEncode(String)

將指定的字串編碼以用於 XML 屬性。

XmlEncode(String)

將指定的字串編碼以用於 XML 屬性。

適用於