HttpWebRequest.Accept Property


Gets or sets the value of the Accept HTTP header.

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

Public Property Accept As String

Property Value

Type: System.String

The value of the Accept HTTP header. The default value is null.

To clear the Accept HTTP header, set the Accept property to null.


The value for this property is stored in WebHeaderCollection. If WebHeaderCollection is set, the property value is lost.

The following code example sets the Accept property.

' Create a 'HttpWebRequest' object.
Dim myHttpWebRequest As HttpWebRequest = WebRequest.Create(myUri)
' Set the 'Accept' property to accept an image of any type.
myHttpWebRequest.Accept = "image/*"
' The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
Dim myHttpWebResponse As HttpWebResponse = CType(myHttpWebRequest.GetResponse(), HttpWebResponse)

Universal Windows Platform
Available since 8
.NET Framework
Available since 1.1
Portable Class Library
Supported in: portable .NET platforms
Available since 2.0
Windows Phone Silverlight
Available since 7.0
Windows Phone
Available since 8.1
Return to top