HttpWebRequest.Accept Eigenschaft

Definition

Ruft den Wert des Accept-HTTP-Headers ab oder legt ihn fest.Gets or sets the value of the Accept HTTP header.

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

Eigenschaftswert

Der Wert des Accept-HTTP-Headers.The value of the Accept HTTP header. Der Standardwert ist nullsein.The default value is null.

Beispiele

Im folgenden Beispiel wird die Eigenschaft auf Accept festgelegt.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() );
// 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)

Hinweise

Legen Sie die Eigenschaft Accept auf nullfest, um den Accept-HTTP-Header zu löschen.To clear the Accept HTTP header, set the Accept property to null.

Hinweis

Der Wert für diese Eigenschaft wird in der WebHeaderCollection gespeichert.The value for this property is stored in WebHeaderCollection. Wenn WebHeaderCollection festgelegt wird, geht der Eigenschaftswert verloren.If WebHeaderCollection is set, the property value is lost.

Gilt für: