WebHeaderCollection.Set Method (String, String)


Sets the specified header to the specified value.

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

override Set : 
        name:string *
        value:string -> unit


Type: System.String

The header to set.

Type: System.String

The content of the header to set.

Exception Condition

name is null or Empty.


The length of value is greater than 65535.


name is a restricted header.


name or value contain invalid characters.

If the header specified in the header does not exist, the Set 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.

The following example uses the Set method to set the value of an existing header.

No code example is currently available or this language may not be supported.

.NET Framework
Available since 1.1
Return to top