Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
[This documentation is for preview only, and is subject to change in later releases. Blank topics are included as placeholders.]
Contains protocol headers associated with a request or response.
Inheritance Hierarchy
System. . :: . .Object
System.Net..::..WebHeaderCollection
Namespace: System.Net
Assembly: System.Http (in System.Http.dll)
Syntax
'Declaration
Public Class WebHeaderCollection
public class WebHeaderCollection
public ref class WebHeaderCollection
type WebHeaderCollection = class end
public class WebHeaderCollection
The WebHeaderCollection type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
![]() |
WebHeaderCollection | Initializes a new instance of the WebHeaderCollection class. |
Top
Properties
| Name | Description | |
|---|---|---|
![]() |
AllKeys | Gets all header names (keys) in the collection. |
![]() |
Count | Gets the number of headers in the collection. |
![]() |
Item | Returns the string value for the header. |
Top
Methods
| Name | Description | |
|---|---|---|
![]() |
Add(String) | Inserts the specified header into the collection. |
![]() |
Add(String, String) | Inserts a header with the specified name and value into the collection. |
![]() |
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 it 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.) |
![]() |
GetValues | Gets an array of header values stored in a header. |
![]() ![]() |
IsRestricted | Tests whether the specified HTTP header can be set for the request. |
![]() |
MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) |
![]() |
Remove | Removes the specified header from the collection. |
![]() |
Set | Sets the specified header to the specified value. |
![]() |
ToByteArray | Infrastructure. Converts the WebHeaderCollection to a byte array.. |
![]() |
ToString | Infrastructure. This method is obsolete. (Overrides Object. . :: . .ToString() () () ().) |
Top
Remarks
The WebHeaderCollection class is generally accessed through WebRequest..::..Headers or WebResponse..::..Headers. Some common headers are considered restricted and are either exposed directly by the API (such as Content-Type) or protected by the system and cannot be changed.
The restricted headers are:
Accept
Connection
Content-Length
Content-Type
Date
Expect
Host
If-Modified-Since
Range
Referer
Transfer-Encoding
User-Agent
Proxy-Connection
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.
.gif)
.gif)
.gif)
.gif)