Accept Property

HttpWebRequest.Accept Property

[ This article is for Windows Phone 8 developers. If you’re developing for Windows 10, see the latest documentation. ]

Gets or sets the value of the Accept HTTP header.

Namespace:  System.Net
Assembly:  System.Net (in System.Net.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.

NoteNote:

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


        // Change this Uri to a public server
        System.Uri myUri = new Uri("http://www.contoso.com");

        // Create a 'HttpWebRequest' object.
        HttpWebRequest myHttpWebRequest=(HttpWebRequest)WebRequest.Create(myUri);

        // Set the 'Accept' property to accept an image of any type.
        myHttpWebRequest.Accept="image/*";

        // Get the 'Accept' property and print the current value
        outputBlock.Text += "HttpWebRequest.Accept: ";
        outputBlock.Text += myHttpWebRequest.Accept;
        outputBlock.Text += "\n";



Windows Phone OS

Supported in: 8.1, 8.0, 7.1, 7.0

Windows Phone

Show:
© 2017 Microsoft