WebHeaderCollection Класс
Определение
Содержит заголовки протокола, связанные с запросом или ответом.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
[<System.Runtime.InteropServices.ComVisible(true)>]
[<System.Serializable>]
type WebHeaderCollection = class
inherit NameValueCollection
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.Headers или WebResponse.Headers .The WebHeaderCollection class is generally accessed through WebRequest.Headers or WebResponse.Headers.
На платформа .NET Framework некоторые общие заголовки считаются ограниченными и предоставляются непосредственно API (например Content-Type
) или защищаются системой и не могут быть изменены.On .NET Framework, 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. Это не относится к .NET Core и .NET 5 + — ни один из заголовков не ограничен.This does not apply to .NET Core and .NET 5+ - none of the headers are restricted there.
Ограниченные заголовки:The restricted headers are:
ПринятьAccept
ПодключениеConnection
Content-LengthContent-Length
Content-TypeContent-Type
DateDate
ExpectExpect
УзелHost
If-Modified-SinceIf-Modified-Since
ДиапазонRange
RefererReferer
Transfer-EncodingTransfer-Encoding
User-AgentUser-Agent
Proxy-ConnectionProxy-Connection
Конструкторы
WebHeaderCollection() |
Инициализирует новый экземпляр класса WebHeaderCollection.Initializes a new instance of the WebHeaderCollection class. |
WebHeaderCollection(SerializationInfo, StreamingContext) |
Инициализирует новый экземпляр класса WebHeaderCollection на основе указанных экземпляров классов SerializationInfo и StreamingContext.Initializes a new instance of the WebHeaderCollection class from the specified instances of the SerializationInfo and StreamingContext classes. |
Свойства
AllKeys |
Возвращает все имена заголовков (ключи) в коллекции.Gets all header names (keys) in the collection. |
Count |
Возвращает число заголовков в коллекции.Gets the number of headers in the collection. |
IsReadOnly |
Возвращает или задает значение, указывающее, является ли экземпляр класса NameObjectCollectionBase доступным только для чтения.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] | |
Item[String] |
Получает или задает запись с указанным ключом в коллекции NameValueCollection.Gets or sets the entry with the specified key in the NameValueCollection. (Унаследовано от NameValueCollection) |
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 в текущую коллекцию NameValueCollection.Copies 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. |
AddWithoutValidate(String, String) |
Вставляет заголовок в коллекцию, не проверяя, находится ли этот заголовок в списке ограниченных заголовков.Inserts a header into the collection without checking whether the header is on the restricted header list. |
BaseAdd(String, Object) |
Добавляет запись с указанным ключом и значением в экземпляр класса NameObjectCollectionBase.Adds an entry with the specified key and value into the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseClear() |
Удаляет все записи из экземпляра класса NameObjectCollectionBase.Removes all entries from the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseGet(Int32) |
Возвращает значение записи по указанному индексу экземпляра класса NameObjectCollectionBase.Gets the value of the entry at the specified index of the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseGet(String) |
Возвращает значение первой записи с указанным ключом из экземпляра класса NameObjectCollectionBase.Gets the value of the first entry with the specified key from the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseGetAllKeys() |
Возвращает массив String, который содержит все ключи экземпляра класса NameObjectCollectionBase.Returns a String array that contains all the keys in the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseGetAllValues() |
Возвращает массив Object, который содержит все значения экземпляра класса NameObjectCollectionBase.Returns an Object array that contains all the values in the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseGetAllValues(Type) |
Возвращает массив указанного типа, который содержит все значения экземпляра класса NameObjectCollectionBase.Returns an array of the specified type that contains all the values in the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseGetKey(Int32) |
Возвращает ключ записи по указанному индексу в экземпляре класса NameObjectCollectionBase.Gets the key of the entry at the specified index of the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseHasKeys() |
Возвращает значение, показывающее, содержит ли экземпляр класса NameObjectCollectionBase записи, в которых значение ключа отлично от |
BaseRemove(String) |
Удаляет записи с указанным ключом из экземпляра класса NameObjectCollectionBase.Removes the entries with the specified key from the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseRemoveAt(Int32) |
Удаляет запись по указанному индексу в экземпляре класса NameObjectCollectionBase.Removes the entry at the specified index of the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseSet(Int32, Object) |
Задает значение записи по указанному индексу экземпляра класса NameObjectCollectionBase.Sets the value of the entry at the specified index of the NameObjectCollectionBase instance. (Унаследовано от NameObjectCollectionBase) |
BaseSet(String, Object) |
Задает значение первой записи с указанным ключом в экземпляре класса NameObjectCollectionBase, если ключ найден; в противном случае добавляет запись с указанным ключом и значением в экземпляр класса NameObjectCollectionBase.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. |
Clear() |
Делает недопустимыми кэшированные массивы и удаляет все записи из коллекции NameValueCollection.Invalidates the cached arrays and removes all entries from the NameValueCollection. (Унаследовано от NameValueCollection) |
CopyTo(Array, Int32) |
Копирует целый массив NameValueCollection в совместимый одномерный массив Array, начиная с заданного индекса целевого массива.Copies 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. (Унаследовано от 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. |
GetEnumerator() |
Возвращает перечислитель, осуществляющий перебор элементов списка NameObjectCollectionBase.Returns an enumerator that iterates through the NameObjectCollectionBase. (Унаследовано от NameObjectCollectionBase) |
GetHashCode() |
Служит хэш-функцией по умолчанию.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() |
Возвращает объект Type для текущего экземпляра.Gets the Type of the current instance. (Унаследовано от Object) |
GetValues(Int32) |
Возвращает массив значений заголовков, хранящийся в позиции |
GetValues(String) |
Получает массив значений заголовка, хранящихся в заголовке.Gets an array of header values stored in a header. |
HasKeys() |
Получает значение, показывающее, содержит ли коллекция NameValueCollection ключи, отличные от |
InvalidateCachedArrays() |
Сбрасывает кэшированные массивы в коллекции до значения |
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() |
Создает неполную копию текущего объекта 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) |
Копирует целый массив NameObjectCollectionBase в совместимый одномерный массив Array, начиная с заданного индекса целевого массива.Copies the entire NameObjectCollectionBase to a compatible one-dimensional Array, starting at the specified index of the target array. (Унаследовано от NameObjectCollectionBase) |
ICollection.IsSynchronized |
Возвращает значение, указывающее на то, является ли доступ к объекту NameObjectCollectionBase синхронизированным (потокобезопасным).Gets a value indicating whether access to the NameObjectCollectionBase object is synchronized (thread safe). (Унаследовано от NameObjectCollectionBase) |
ICollection.SyncRoot |
Возвращает объект, который позволяет синхронизировать доступ к объекту NameObjectCollectionBase.Gets an object that can be used to synchronize access to the NameObjectCollectionBase object. (Унаследовано от NameObjectCollectionBase) |
IEnumerable.GetEnumerator() |
Возвращает перечислитель, с помощью которого можно выполнять итерацию элементов экземпляра WebHeaderCollection.Returns an enumerator that can iterate through the WebHeaderCollection instance. |
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 в объект IQueryable.Converts an IEnumerable to an IQueryable. |