HttpResponseHeaderCollection.Allow Propiedad

Definición

Obtiene la httpMethodHeaderValueCollection de los objetos HttpMethod que representan el valor de un encabezado HTTP Allow en una respuesta HTTP.

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

Valor de propiedad

Colección de objetos HttpMethod que representan el valor de un encabezado HTTP Allow en una respuesta HTTP. Una colección vacía significa que el encabezado no está presente.

Comentarios

La propiedad Allow representa el valor de un encabezado HTTP Allow en una respuesta HTTP. El encabezado Allow es una lista de métodos HTTP (GET, PUT y POST, por ejemplo) permitidos por el servidor HTTP.

En el código de ejemplo siguiente se muestra un método para obtener y establecer el encabezado Allow en un objeto HttpResponseMessage mediante la propiedad Allow en el 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());
}

Se aplica a

Consulte también