HttpResponseHeaderCollection.Allow Propriedade

Definição

Obtém o HttpMethodHeaderValueCollection de objetos HttpMethod que representam o valor de um cabeçalho Permitir HTTP em uma resposta HTTP.

public:
 property HttpMethodHeaderValueCollection ^ Allow { HttpMethodHeaderValueCollection ^ get(); };
HttpMethodHeaderValueCollection Allow();
public HttpMethodHeaderValueCollection Allow { get; }
var httpMethodHeaderValueCollection = httpResponseHeaderCollection.allow;
Public ReadOnly Property Allow As HttpMethodHeaderValueCollection

Valor da propriedade

A coleção de objetos HttpMethod que representam o valor de um cabeçalho Allow HTTP em uma resposta HTTP. Uma coleção vazia significa que o cabeçalho está ausente.

Comentários

A propriedade Allow representa o valor de um cabeçalho Permitir HTTP em uma resposta HTTP. O cabeçalho Allow é uma lista de métodos HTTP (GET, PUT e POST, por exemplo) permitidos pelo servidor HTTP.

O código de exemplo a seguir mostra um método para obter e definir o cabeçalho Allow em um objeto HttpResponseMessage usando a propriedade Allow no objeto HttpResponseHeaderCollection .

public void DemonstrateHeaderResponseAllow() {
    var response = new HttpResponseMessage();

    // Set the header with a string
    response.Headers.Allow.TryParseAdd ("GET");

    // Set the header with a strong type
    response.Headers.Allow.Add(HttpMethod.Patch);

    // Get the strong type out
    foreach (var value in response.Headers.Allow) {
        System.Diagnostics.Debug.WriteLine("Allow value: {0}", value.Method);
    }

    // The ToString() is useful for diagnostics, too.
    System.Diagnostics.Debug.WriteLine("The Allow ToString() results: {0}", response.Headers.Allow.ToString());
}

Aplica-se a

Confira também