WebHeaderCollection 類別

定義

包含與要求或回應關聯的通訊協定 (Protocol) 標頭。Contains protocol headers associated with a request or response.

public ref class WebHeaderCollection sealed : System::Collections::IEnumerable
public ref class WebHeaderCollection : System::Collections::Specialized::NameValueCollection, System::Runtime::Serialization::ISerializable
public ref class WebHeaderCollection : System::Collections::Specialized::NameValueCollection
public sealed class WebHeaderCollection : System.Collections.IEnumerable
public class WebHeaderCollection : System.Collections.Specialized.NameValueCollection, System.Runtime.Serialization.ISerializable
[System.Runtime.InteropServices.ComVisible(true)]
[System.Serializable]
public class WebHeaderCollection : System.Collections.Specialized.NameValueCollection, System.Runtime.Serialization.ISerializable
public class WebHeaderCollection : System.Collections.Specialized.NameValueCollection
type WebHeaderCollection = class
    interface IEnumerable
type WebHeaderCollection = class
    inherit NameValueCollection
    interface IEnumerable
    interface ISerializable
type WebHeaderCollection = class
    inherit NameValueCollection
    interface ISerializable
Public NotInheritable Class WebHeaderCollection
Implements IEnumerable
Public Class WebHeaderCollection
Inherits NameValueCollection
Implements ISerializable
Public Class WebHeaderCollection
Inherits NameValueCollection
繼承
WebHeaderCollection
繼承
屬性
實作

備註

WebHeaderCollection 類別通常是透過 WebRequest.HeadersWebResponse.Headers來存取。The WebHeaderCollection class is generally accessed through WebRequest.Headers or WebResponse.Headers. 某些常見的標頭會被視為受限制,而且會直接由 API (例如 Content-Type)公開或由系統保護,而且無法變更。Some common headers are considered restricted and are either exposed directly by the API (such as Content-Type) or protected by the system and cannot be changed.

限制的標頭為:The restricted headers are:

  • AcceptAccept

  • ConnectionConnection

  • Content-LengthContent-Length

  • Content-TypeContent-Type

  • DateDate

  • ExpectExpect

  • HostHost

  • If-Modified-SinceIf-Modified-Since

  • 範圍Range

  • 推薦者Referer

  • Transfer-EncodingTransfer-Encoding

  • User-AgentUser-Agent

  • Proxy-連線Proxy-Connection

建構函式

WebHeaderCollection()

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

屬性

AllKeys

取得集合中的所有標頭名稱 (索引鍵)。Gets all header names (keys) in the collection.

Count

取得集合中的標頭數目。Gets the number of headers in the collection.

IsReadOnly

Gets or sets a value indicating whether the NameObjectCollectionBase instance is read-only.Gets or sets a value indicating whether the NameObjectCollectionBase instance is read-only.

(繼承來源 NameObjectCollectionBase)
Item[HttpRequestHeader]

取得或設定指定的要求標頭。Gets or sets the specified request header.

Item[HttpResponseHeader]

取得或設定指定的回應標頭。Gets or sets the specified response header.

Item[Int32]

移除位於 NameValueCollection 之指定索引處的項目。Gets the entry at the specified index of the NameValueCollection.

(繼承來源 NameValueCollection)
Item[String]
Keys

取得集合中的標頭名稱 (索引鍵) 集合。Gets the collection of header names (keys) in the collection.

方法

Add(HttpRequestHeader, String)

將具有指定值的指定標頭插入至集合。Inserts the specified header with the specified value into the collection.

Add(HttpResponseHeader, String)

將具有指定值的指定標頭插入至集合。Inserts the specified header with the specified value into the collection.

Add(NameValueCollection)

將指定 NameValueCollection 中的項目複製到目前的 NameValueCollectionCopies the entries in the specified NameValueCollection to the current NameValueCollection.

(繼承來源 NameValueCollection)
Add(String)

將指定標頭插入至集合。Inserts the specified header into the collection.

Add(String, String)

將具有指定名稱和值的標頭插入至集合。Inserts a header with the specified name and value into the collection.

BaseAdd(String, Object)

Adds an entry with the specified key and value into the NameObjectCollectionBase instance.Adds an entry with the specified key and value into the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseClear()

Removes all entries from the NameObjectCollectionBase instance.Removes all entries from the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseGet(Int32)

Gets the value of the entry at the specified index of the NameObjectCollectionBase instance.Gets the value of the entry at the specified index of the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseGet(String)

Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance.Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseGetAllKeys()

Returns a String array that contains all the keys in the NameObjectCollectionBase instance.Returns a String array that contains all the keys in the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseGetAllValues()

Returns an Object array that contains all the values in the NameObjectCollectionBase instance.Returns an Object array that contains all the values in the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseGetAllValues(Type)

Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance.Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseGetKey(Int32)

Gets the key of the entry at the specified index of the NameObjectCollectionBase instance.Gets the key of the entry at the specified index of the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseHasKeys()

Gets a value indicating whether the NameObjectCollectionBase instance contains entries whose keys are not null.Gets a value indicating whether the NameObjectCollectionBase instance contains entries whose keys are not null.

(繼承來源 NameObjectCollectionBase)
BaseRemove(String)

Removes the entries with the specified key from the NameObjectCollectionBase instance.Removes the entries with the specified key from the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseRemoveAt(Int32)

Removes the entry at the specified index of the NameObjectCollectionBase instance.Removes the entry at the specified index of the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseSet(Int32, Object)

Sets the value of the entry at the specified index of the NameObjectCollectionBase instance.Sets the value of the entry at the specified index of the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
BaseSet(String, Object)

Sets the value of the first entry with the specified key in the NameObjectCollectionBase instance, if found; otherwise, adds an entry with the specified key and value into the NameObjectCollectionBase instance.Sets the value of the first entry with the specified key in the NameObjectCollectionBase instance, if found; otherwise, adds an entry with the specified key and value into the NameObjectCollectionBase instance.

(繼承來源 NameObjectCollectionBase)
Clear()

移除集合中的所有標頭。Removes all headers from the collection.

CopyTo(Array, Int32)

從目標陣列的指定索引開始,將整個 NameValueCollection 複製到相容的一維 ArrayCopies the entire NameValueCollection to a compatible one-dimensional Array, starting at the specified index of the target array.

(繼承來源 NameValueCollection)
Equals(Object)

Determines whether the specified object is equal to the current object.Determines whether the specified object is equal to the current object.

(繼承來源 Object)
Get(Int32)

取得集合中特定標頭的值 (由集合的索引指定)。Gets the value of a particular header in the collection, specified by an index into the collection.

Get(String)

取得集合中特定標頭的值 (由標頭的名稱指定)。Gets the value of a particular header in the collection, specified by the name of the header.

GetEnumerator()

傳回可逐一查看 WebHeaderCollection 執行個體的列舉值。Returns an enumerator that can iterate through the WebHeaderCollection instance.

GetHashCode()

Serves as the default hash function.Serves as the default hash function.

(繼承來源 Object)
GetKey(Int32)

取得集合中指定位置的標頭名稱。Gets the header name at the specified position in the collection.

GetObjectData(SerializationInfo, StreamingContext)

SerializationInfo 中填入序列化目標物件所需的資料。Populates a SerializationInfo with the data needed to serialize the target object.

GetType()

Gets the Type of the current instance.Gets the Type of the current instance.

(繼承來源 Object)
GetValues(Int32)

取得儲存於標頭集合的 index 位置之標頭值的陣列。Gets an array of header values stored in the index position of the header collection.

GetValues(String)

取得儲存於標頭中的標頭值陣列。Gets an array of header values stored in a header.

HasKeys()

取得值,表示 NameValueCollection 是否包含非 null 的索引鍵。Gets a value indicating whether the NameValueCollection contains keys that are not null.

(繼承來源 NameValueCollection)
InvalidateCachedArrays()

將集合的快取陣列重設為 nullResets the cached arrays of the collection to null.

(繼承來源 NameValueCollection)
IsRestricted(String)

測試是否可為要求設定指定的 HTTP 標頭。Tests whether the specified HTTP header can be set for the request.

IsRestricted(String, Boolean)

測試是否可以設定要求或回應之指定的 HTTP 標頭。Tests whether the specified HTTP header can be set for the request or the response.

MemberwiseClone()

Creates a shallow copy of the current Object.Creates a shallow copy of the current Object.

(繼承來源 Object)
OnDeserialization(Object)

實作 ISerializable 介面,並於還原序列化完成時引發還原序列化事件。Implements the ISerializable interface and raises the deserialization event when the deserialization is complete.

Remove(HttpRequestHeader)

從集合中移除指定的標頭。Removes the specified header from the collection.

Remove(HttpResponseHeader)

從集合中移除指定的標頭。Removes the specified header from the collection.

Remove(String)

從集合中移除指定的標頭。Removes the specified header from the collection.

Set(HttpRequestHeader, String)

將指定的標頭設定為指定的值。Sets the specified header to the specified value.

Set(HttpResponseHeader, String)

將指定的標頭設定為指定的值。Sets the specified header to the specified value.

Set(String, String)

將指定的標頭設定為指定的值。Sets the specified header to the specified value.

ToByteArray()

WebHeaderCollection 轉換成位元組陣列。Converts the WebHeaderCollection to a byte array.

ToString()

這個方法已過時。This method is obsolete.

明確介面實作

ICollection.CopyTo(Array, Int32)

Copies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.Copies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array.

(繼承來源 NameObjectCollectionBase)
ICollection.IsSynchronized

Gets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe).Gets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe).

(繼承來源 NameObjectCollectionBase)
ICollection.SyncRoot

Gets an object that can be used to synchronize access to the NameObjectCollectionBase object.Gets an object that can be used to synchronize access to the NameObjectCollectionBase object.

(繼承來源 NameObjectCollectionBase)
IEnumerable.GetEnumerator()
ISerializable.GetObjectData(SerializationInfo, StreamingContext)

將這個執行個體序列化為指定的 SerializationInfo 物件。Serializes this instance into the specified SerializationInfo object.

擴充方法

Cast<TResult>(IEnumerable)

IEnumerable 的項目轉換成指定的型別。Casts the elements of an IEnumerable to the specified type.

OfType<TResult>(IEnumerable)

根據指定的型別來篩選 IEnumerable 的項目。Filters the elements of an IEnumerable based on a specified type.

AsParallel(IEnumerable)

啟用查詢的平行化作業。Enables parallelization of a query.

AsQueryable(IEnumerable)

IEnumerable 轉換成 IQueryableConverts an IEnumerable to an IQueryable.

適用於