HttpResponse.HeaderEncoding 屬性

定義

取得或設定 Encoding 物件,表示目前標頭輸出資料流的編碼方式。Gets or sets an Encoding object that represents the encoding for the current header output stream.

public:
 property System::Text::Encoding ^ HeaderEncoding { System::Text::Encoding ^ get(); void set(System::Text::Encoding ^ value); };
public System.Text.Encoding HeaderEncoding { get; set; }
member this.HeaderEncoding : System.Text.Encoding with get, set
Public Property HeaderEncoding As Encoding

屬性值

Encoding,包含目前標頭字元集的相關資訊。An Encoding that contains information about the character set for the current header.

例外狀況

編碼的值是 nullThe encoding value is null.

編碼的值是 UnicodeThe encoding value is Unicode.

-或--or- 已傳送標頭。The headers have already been sent.

備註

Encoding ASCIIEncoding屬性可UTF7Encoding讓您使用、 、或UTF8Encoding物件,來停用或變更回應標頭上的物件。 UnicodeEncoding HeaderEncodingThe HeaderEncoding property gives you the ability to disable or change the Encoding object on a response header by using the ASCIIEncoding, UnicodeEncoding, UTF7Encoding, or UTF8Encoding object. 預設的編碼值是UTF8Encoding類別。The default encoding value is the UTF8Encoding class.

藉由變更HeaderEncoding屬性的類型,您可能會增加某些惡意攻擊的風險,或造成敏感性資料透過回應標頭傳送。By changing the type of the HeaderEncoding property, you can potentially increase the risk of certain malicious attacks or cause sensitive data to be sent through the response header. 在部分情況下,可以避免標頭插入式攻擊, HeaderEncoding方法是將回應的屬性保留為預設設定。Header injection attacks can be avoided, in part, by leaving the HeaderEncoding property of a response to the default setting. 對易受攻擊的應用程式的攻擊,可能會在回應標頭中傳回信賴資料。An attack against a vulnerable application could echo back entrusted data as part of a response header. 如果因為標頭中的接續行需求而停用,或是根據不受信任資料的結果來建立任何標頭,則應該先驗證標頭資料,然後再傳送至回應資料流程。HeaderEncodingIf the HeaderEncoding is disabled because of a requirement for continuation lines in a header or if any header is constructed based on the result of untrusted data, the header data should be validated before sending to the response stream.

適用於