HttpWebRequest.Accept Property
.NET Framework 4.5
Gets or sets the value of the Accept HTTP header.
Assembly: System (in System.dll)
To clear the Accept HTTP header, set the Accept property to null.
Note |
|---|
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. myHttpWebRequest.Accept="image/*"; // The response object of 'HttpWebRequest' is assigned to a 'HttpWebResponse' variable. HttpWebResponse myHttpWebResponse=(HttpWebResponse)myHttpWebRequest.GetResponse();
Windows 8, Windows Server 2012, Windows 7, Windows Vista SP2, Windows Server 2008 (Server Core Role not supported), Windows Server 2008 R2 (Server Core Role supported with SP1 or later; Itanium not supported)
The .NET Framework does not support all versions of every platform. For a list of the supported versions, see .NET Framework System Requirements.
Note