.NET Framework Class Library for Silverlight
WebHeaderCollection Class

Contains protocol headers associated with a request or response.

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

Visual Basic (Declaration)
Public NotInheritable Class WebHeaderCollection _
    Implements IEnumerable
Visual Basic (Usage)
Dim instance As WebHeaderCollection
C#
public sealed class WebHeaderCollection : IEnumerable
Remarks

The WebHeaderCollection class is generally accessed through WebRequest..::.Headers property.

The Item property can be used to get the value of a header stored in a WebHeaderCollection 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.

The Item property can be used to set custom headers in a WebHeaderCollection object for use by the WebClient or HttpWebRequest objects.

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 WebHeaderCollection object. Any attempt to set one of these restricted headers in the WebHeaderCollection object associated with a HttpWebRequest object throws an exception. 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 include, but are not limited to the following:

  • Accept

  • Accept-Charset

  • Accept-Encoding

  • Accept-Language

  • Accept-Ranges

  • Age

  • Allow

  • Allowed

  • Authorization

  • Connect

  • Connection

  • Content-Length

  • Content-Location

  • Content-Range

  • Content-Transfer-Encoding

  • Content-Type

  • Cookie

  • Date

  • Delete

  • ETag

  • Expect

  • Get

  • Head

  • Host

  • Keep-Alive

  • Last-Modified

  • Location

  • Max-Forwards

  • Options

  • Post

  • Proxy-Authenticate

  • Proxy-Authorization

  • Proxy-Connection

  • Public

  • Put

  • Range

  • Referer

  • Request-Range

  • TE

  • Trace

  • Trailer

  • Transfer-Encoding

  • Upgrade

  • User-Agent

  • Via

  • Warning

  • Uri

  • X-Flash-Version

  • Retry-After

  • Server

  • Vary

  • WWW-Authenticate

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:

  • Content-Encoding

  • Content-Language

  • Content-Location

  • Content-MD5

  • Content-Range

  • Content-Type

  • Expires

  • Last-Modified

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:

  • Content-Location

  • Content-Range

  • Last-Modified

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.

Inheritance Hierarchy

System..::.Object
  System.Net..::.WebHeaderCollection
Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Platforms

For a list of the operating systems and browsers that are supported by Silverlight, see Supported Operating Systems and Browsers.

See Also

Reference

Tags :


Page view tracker