Accept Property

HttpWebRequest.Accept Property


Gets or sets the value of the Accept HTTP header.

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

public string Accept { get; set; }

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.
HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create(myUri);
// Set the 'Accept' property to accept an image of any type.
// The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable.
HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();

Universal Windows Platform
Available since 4.5
.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
© 2015 Microsoft