System.Net.WebHeaderCollection.Set Method

Sets the specified header to the specified value.

Syntax

public override void Set (string name, string value)

Parameters

name
The header to set.
value
The content of the header to set.

Exceptions

TypeReason
ArgumentNullException name is null or string.Empty.
ArgumentException

name 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 the header does not exist, the WebHeaderCollection.Set(HttpRequestHeader, string) method inserts a new header into the list of header name/value pairs.

If the header specified in header is already present, value replaces the existing value.

Requirements

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