AntiXssEncoder 類別

定義

將字串編碼以用於 HTML、XML、CSS 和 URL 字串中。Encodes a string for use in HTML, XML, CSS, and URL strings.

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 HttpResponseHeaderYou can use the AntiXssEncoder class to override the HttpEncoder class that is used by default to encode and decode strings in methods of classes such as HttpUtility, HttpServerUtility, and HttpResponseHeader.

AntiXssEncoder 類別中,在安全清單中找不到的所有字元都是由 HtmlAttributeEncode 和方法所編碼 HtmlEncodeIn the AntiXssEncoder class, all characters that are not found in the safe list are encoded by the HtmlAttributeEncode and HtmlEncode methods.

若要將 HttpEncoder 類別取代為 AntiXssEncoder 類別,請使用 Web.config 檔 encoderType 中 HTTPRuntime 元素的屬性來註冊該類別,如下列範例所示:To replace the HttpEncoder class with the AntiXssEncoder class, register it using the encoderType attribute of the httpRuntime element in the Web.config file, as shown in following example:

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

您可以在 HtmlAttributeEncodeHtmlEncodeXmlAttributeEncode 和方法的備註中找到不同編碼方法的預設安全字元清單 XmlEncodeA list of default safe characters for different encoding methods can be found in the remarks for the HtmlAttributeEncode, HtmlEncode, XmlAttributeEncode, and XmlEncode methods. 您可以使用方法來修改預設的安全清單 MarkAsSafeThe default safe list can be modified by using the MarkAsSafe method.

建構函式

AntiXssEncoder()

初始化 AntiXssEncoder 類別的新執行個體。Initializes a new instance of the AntiXssEncoder class.

方法

CssEncode(String)

將指定的字串編碼以用於階層式樣式表 (CSS) 中。Encodes the specified string for use in cascading style sheets (CSS).

Equals(Object)

判斷指定的物件是否等於目前的物件。Determines whether the specified object is equal to the current object.

(繼承來源 Object)
GetHashCode()

做為預設雜湊函式。Serves as the default hash function.

(繼承來源 Object)
GetType()

取得目前執行個體的 TypeGets the Type of the current instance.

(繼承來源 Object)
HeaderNameValueEncode(String, String, String, String)

將標頭名稱及值編碼為可當做 HTTP 標頭使用的字串。Encodes a header name and value into a string that can be used as an HTTP header.

(繼承來源 HttpEncoder)
HtmlAttributeEncode(String, TextWriter)

將指定的字串編碼並輸出,以用於 HTML 屬性中。Encodes and outputs the specified string for use in an HTML attribute.

HtmlDecode(String, TextWriter)

將 HTML 編碼字串中的值解碼。Decodes a value from an HTML-encoded string.

(繼承來源 HttpEncoder)
HtmlEncode(String, Boolean)

將指定的字串編碼以做為 HTML 標記中的文字,並選擇性指定是否要使用 HTML 4.0 具名實體。Encodes the specified string for use as text in HTML markup and optionally specifies whether to use HTML 4.0 named entities.

HtmlEncode(String, TextWriter)

將指定的字串編碼以做為 HTML 標記中的文字,並使用指定的文字寫入器來輸出字串。Encodes the specified string for use as text in HTML markup and outputs the string by using the specified text writer.

HtmlFormUrlEncode(String)

將指定的字串編碼以用來提交 MIME 類型為 "application/x-www-form-urlencoded" 的表單。Encodes the specified string for use in form submissions whose MIME type is "application/x-www-form-urlencoded".

HtmlFormUrlEncode(String, Encoding)

使用指定的字元編碼類型,將指定的字串編碼以用於 MIME 類型為 "application/x-www-form-urlencoded" 的表單提交。Encodes the specified string for form submissions whose MIME type is "application/x-www-form-urlencoded" by using the specified character encoding type.

HtmlFormUrlEncode(String, Int32)

使用指定的字碼頁,將指定的字串編碼以用來提交 MIME 類型為 "application/x-www-form-urlencoded" 的表單。Encodes the specified string for use in form submissions whose MIME type is "application/x-www-form-urlencoded" by using the specified code page.

JavaScriptStringEncode(String)

編碼字串。Encodes a string.

(繼承來源 HttpEncoder)
MarkAsSafe(LowerCodeCharts, LowerMidCodeCharts, MidCodeCharts, UpperMidCodeCharts, UpperCodeCharts)

將來自指定之 Unicode 字碼表的字元標記為安全。Marks characters from the specified Unicode code charts as safe.

MemberwiseClone()

建立目前 Object 的淺層複製。Creates a shallow copy of the current Object.

(繼承來源 Object)
ToString()

傳回代表目前物件的字串。Returns a string that represents the current object.

(繼承來源 Object)
UrlEncode(Byte[], Int32, Int32)

從位元組陣列中指定的位移開始將指定數目的位元組編碼,以用於 URL 中Encodes the specified byte array for use in a URL, starting at the specified offset in the byte array and encoding the specified number of bytes.

UrlEncode(String)

將指定的字串編碼以用於 URL 中。Encodes the specified string for use in a URL.

UrlEncode(String, Encoding)

使用指定的字元編碼類型,將指定的字串編碼以用於 URL 中。Encodes the specified string for use in a URL by using the specified character encoding type.

UrlEncode(String, Int32)

使用指定的字碼頁,將指定的字串編碼以用於 URL 中。Encodes the specified string for use in a URL by using the specified code page.

UrlPathEncode(String)

將路徑字串編碼以用於 URL 中。Encodes path strings for use in a URL.

XmlAttributeEncode(String)

將指定的字串編碼以用於 XML 屬性中。Encodes the specified string for use in XML attributes.

XmlEncode(String)

將指定的字串編碼以用於 XML 屬性中。Encodes the specified string for use in XML attributes.

適用於