System.Net.WebHeaderCollection.Add Method

Inserts a header with the specified name and value into the collection.

Syntax

public override void Add (string name, string value)

Parameters

name
The header to add to the collection.
value
The content of the header.

Exceptions

TypeReason
ArgumentException

name is null or string.Empty, or contains invalid characters.

-or-

name is a protected header that can only be set with a property accessor or by the system.

-or-

value contains invalid characters.

Remarks

If the header specified in name does not exist, the WebHeaderCollection.Add(HttpRequestHeader, string) method inserts a new header into the list of header name/value pairs.

If the header specified in name is already present, value is added to the existing comma-separated list of values associated with name.

Requirements

Namespace: System.Net
Assembly: System (in System.dll)
Assembly Versions: 1.0.5000.0, 2.0.0.0, 4.0.0.0