HttpWebRequest.Accept Właściwość

Definicja

Pobiera lub ustawia wartość nagłówka Accept HTTP.

public:
 property System::String ^ Accept { System::String ^ get(); void set(System::String ^ value); };
public string Accept { get; set; }
public string? Accept { get; set; }
member this.Accept : string with get, set
Public Property Accept As String

Wartość właściwości

String

Wartość nagłówka Accept HTTP. Wartość domyślna to null.

Przykłady

Poniższy przykład kodu ustawia Accept właściwość .

// 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() );
// 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();
' 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)

Uwagi

Aby wyczyścić Accept nagłówek HTTP, ustaw Accept właściwość na null.

Uwaga

Wartość tej właściwości jest przechowywana w obiekcie WebHeaderCollection. Jeśli parametr WebHeaderCollection jest ustawiony, wartość właściwości zostanie utracona.

Dotyczy