Gets or sets a collection of header name/value pairs associated with the request.
Assembly: System (in System.dll)
Some common headers are considered restricted and are protected by the system and cannot be set or changed in a WebHeaderCollection object. Any attempt to set one of these restricted headers in the WebHeaderCollection object associated with a WebClient object will throw an exception later when attempting to send the WebClient request.
Restricted headers protected by the system include, but are not limited to the following:
In addition, some other headers are also restricted when using a WebClient object. These restricted headers include, but are not limited to the following:
Expect (when the value is set to "100-continue"
The HttpWebRequest class has properties for setting some of the above headers. If it is important for an application to set these headers, then the HttpWebRequest class should be used instead of the WebRequest class.
You should not assume that the header values will remain unchanged, because Web servers and caches may change or add headers to a Web request.