February 14, 2014
Contains protocol headers associated with a request or response.
Assembly: System.Net (in System.Net.dll)
Thetype exposes the following members.
|Equals(Object)||Determines whether the specified Object is equal to the current Object. (Inherited from Object.)|
|Finalize||Allows an object to try to free resources and perform other cleanup operations before the Object is reclaimed by garbage collection. (Inherited from Object.)|
|GetHashCode||Serves as a hash function for a particular type. (Inherited from Object.)|
|GetType||Gets the Type of the current instance. (Inherited from Object.)|
|MemberwiseClone||Creates a shallow copy of the current Object. (Inherited from Object.)|
|ToString||Returns a String that represents the current . (Overrides Object.ToString().)|
The class is generally accessed through WebRequest.Headers property.
The Item property can be used to get the value of a header stored in a object. The Item[HttpRequestHeader] property can be used to get the value of common headers defined in the HttpRequestHeader enumeration. The Item[String] property can be used to get the value of custom headers and those headers not defined in the HttpRequestHeader enumeration.
Some common headers are considered restricted and are either exposed directly (such as Content-Type) or protected by the system and cannot be set or changed in a object. Any attempt to set one of these restricted headers in the object associated with a HttpWebRequest object throws an exception. Any attempt to set one of these restricted headers in the object associated with a WebClient object will throw an exception later when attempting to send the WebClient request.
For security reasons, sending specific headers to a cross-domain site is restricted 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 Headers 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.
If you use this API in your app, you must specify the following capabilities in the app manifest. Otherwise, your app might not work correctly or it might exit unexpectedly.
Windows Phone 8, Windows Phone OS 7.1
For more info, see App capabilities and hardware requirements for Windows Phone.