Share via


WebHeaderCollection Class

[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]

Contains protocol headers associated with a request or response.

Inheritance Hierarchy

System. . :: . .Object
  System.Net..::..WebHeaderCollection

Namespace:  System.Net
Assembly:  System.Http (in System.Http.dll)

Syntax

'Declaration
Public Class WebHeaderCollection
public class WebHeaderCollection
public ref class WebHeaderCollection
type WebHeaderCollection =  class end
public class WebHeaderCollection

The WebHeaderCollection type exposes the following members.

Constructors

  Name Description
Public method WebHeaderCollection Initializes a new instance of the WebHeaderCollection class.

Top

Properties

  Name Description
Public property AllKeys Gets all header names (keys) in the collection.
Public property Count Gets the number of headers in the collection.
Public property Item Returns the string value for the header.

Top

Methods

  Name Description
Public method Add(String) Inserts the specified header into the collection.
Public method Add(String, String) Inserts a header with the specified name and value into the collection.
Public method Equals(Object) Determines whether the specified Object is equal to the current Object. (Inherited from Object.)
Protected method Finalize Allows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection. (Inherited from Object.)
Public method GetHashCode Serves as a hash function for a particular type. (Inherited from Object.)
Public method GetType Gets the Type of the current instance. (Inherited from Object.)
Public method GetValues Gets an array of header values stored in a header.
Public methodStatic member IsRestricted Tests whether the specified HTTP header can be set for the request.
Protected method MemberwiseClone Creates a shallow copy of the current Object. (Inherited from Object.)
Public method Remove Removes the specified header from the collection.
Public method Set Sets the specified header to the specified value.
Public method ToByteArray Infrastructure. Converts the WebHeaderCollection to a byte array..
Public method ToString Infrastructure. This method is obsolete. (Overrides Object. . :: . .ToString() () () ().)

Top

Remarks

The WebHeaderCollection class is generally accessed through WebRequest..::..Headers or WebResponse..::..Headers. 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:

  • Accept

  • Connection

  • Content-Length

  • Content-Type

  • Date

  • Expect

  • Host

  • If-Modified-Since

  • Range

  • Referer

  • Transfer-Encoding

  • User-Agent

  • Proxy-Connection

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

System.Net Namespace