Gets or sets a collection of header name/value pairs associated with the request.
Assembly: System.Net (in System.Net.dll)
The property contains a WebHeaderCollection instance containing header information that the WebClient sends with the request. This is an unrestricted collection of headers, so setting headers that are restricted by WebRequest descendants such as HttpWebRequest is allowed.
Some headers are considered restricted and are either exposed directly (such as Content-Type) or protected by the system and cannot be set in a WebHeaderCollection object. Any attempt to set one of these restricted headers in the WebHeaderCollection object using the Item[HttpRequestHeader] or Item[String] property or throws an exception. If the WebHeaderCollection object is associated with a HttpWebRequest object, the exception is thrown by the Item[HttpRequestHeader] property. If the WebHeaderCollection object is associated with a WebClient object, the exception is thrown when an attempt to send the WebClient request occurs.
For a list of restricted headers, see the Remarks in the WebHeaderCollection class.
For security reasons, the Silverlight runtime restricts the WebClient class from sending specific headers to a cross-domain site unless the header is allowed by the security policy applicable to the target cross-domain site. This restriction applies to resources from locations other than the site of origin. The Authorization header can be set using the property. However to set the credentials properly, the cross-domain policy applicable to the target must have the http-request-headers set to allow the Authorization header to be sent.
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.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.