HttpWebRequest.Accept Propiedad

Definición

Obtiene o establece el valor del encabezado HTTP Accept.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; }
public string? Accept { get; set; }
member this.Accept : string with get, set
Public Property Accept As String

Valor de propiedad

String

Valor del encabezado HTTP Accept.The value of the Accept HTTP header. El valor predeterminado es null.The default value is null.

Ejemplos

En el ejemplo de código siguiente se establece la Accept propiedad.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)

Comentarios

Para borrar el Accept encabezado HTTP, establezca la Accept propiedad en null .To clear the Accept HTTP header, set the Accept property to null.

Nota

El valor de esta propiedad se almacena en WebHeaderCollection.The value for this property is stored in WebHeaderCollection. Si se establece WebHeaderCollection, se pierde el valor de propiedad.If WebHeaderCollection is set, the property value is lost.

Se aplica a