Share via


HttpWebRequest.Headers Property

A collection of HTTP headers stored as name/value pairs.

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

Syntax

public override WebHeaderCollection Headers { get; set; }

Property Value

A WebHeaderCollection that contains the name/value pairs that make up the headers for the HTTP request.

Remarks

The following header values are set through properties on the HttpWebRequest class: Accept, Connection, Content-Length, Content-Type, Expect, Range, Referer, Transfer-Encoding, and User-Agent. Trying to set these header values by using the method WebHeaderCollection.Add(string, string) will raise an exception. Date and Host are set internally.

Exceptions

Exception type Condition
InvalidOperationException The headers cannot be changed, because the request was already submitted.

Version Information

Available in the .NET Micro Framework versions 4.0 and 4.1.

See Also

Reference

HttpWebRequest Class
HttpWebRequest Members
System.Net Namespace