HttpWebRequest.Accept Propriedade
Definição
Obtém ou define o valor do cabeçalho 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 da propriedade
O valor do cabeçalho HTTP Accept.The value of the Accept HTTP header. O valor padrão é null.The default value is null.
Exemplos
O exemplo de código a seguir define a Accept propriedade.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)
Comentários
Para limpar o Accept cabeçalho HTTP, defina a Accept propriedade como null .To clear the Accept HTTP header, set the Accept property to null.
Observação
O valor dessa propriedade é armazenado em WebHeaderCollection.The value for this property is stored in WebHeaderCollection. Se WebHeaderCollection for definido, o valor da propriedade será perdido.If WebHeaderCollection is set, the property value is lost.