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 object. (Inherited from Object.)|
In Silverlight for Windows Phone, this member is overridden by ToString().
In XNA Framework, this member is overridden by 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.
Restricted headers include, but are not limited to the following:
Many of these restricted headers are set by the web browser that hosts the Silverlight application.
In addition, some headers are also restricted when the Method property is set to an HTTP GET protocol verb. These restricted headers include, but are not limited to the following:
In addition, some headers are also restricted when the Method property is set to an HTTP POST protocol verb. These restricted headers include, but are not limited to the following:
For security reasons, the Silverlight runtime restricts 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 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. For more information, see Network Security Access Restrictions in Silverlight and URL Access Restrictions in Silverlight.
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.
The Mozilla FireFox browser does not currently set the Referer header on HTTP GET requests. The Internet Explorer and Safari web browsers do properly set the Referer header on HTTP GET requests. As a result, a Silverlight application hosted in Firefox can't support the Referer header being set on any GET requests applicable to browser HTTP handling for BrowserHttp. The Referer header is properly set on HTTP POST requests by Firefox, Internet Explorer, and Safari applicable to browser HTTP handling for BrowserHttp.
The Referer header is properly set on all HTTP requests applicable to client HTTP handling for ClientHttp regardless of the web browser.
For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.