Windows apps
Collapse the table of content
Expand the table of content
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

WebHeaderCollection.Item Property (HttpRequestHeader)

Gets or sets the specified request header.

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

public string this[
	HttpRequestHeader header
] { get; set; }


Type: System.Net.HttpRequestHeader
The request header value.

Property Value

Type: System.String
A String instance containing the specified header value.


On a get or set operation, the request header specified in the header parameter is a restricted header. The WebHeaderCollection class does not allow a user to get or set instances of this restricted header in this WebHeaderCollection instance.

The Item[HttpRequestHeader] property can be used to get the value of a common header defined in the HttpRequestHeader enumeration for use by WebClient or HttpWebRequest classes.

The Item[String] property can also be used to set the name and value for a header in a WebHeaderCollection. When setting a header, both a header and value parameter must be passed. The value parameter must be specified as a string.

Some common headers defined in the HttpRequestHeader enumeration 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 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 later when an attempt to send the WebClient request occurs.

For a list of restricted headers, see the Remarks in the WebHeaderCollection class.


Supported in: 5, 4, 3

Silverlight for Windows Phone

Supported in: Windows Phone OS 7.1, Windows Phone OS 7.0

XNA Framework

Supported in: Windows Phone OS 7.0

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

Community Additions

© 2016 Microsoft