Skip to main content

Windows Dev Center

HttpResponseHeaderCollection.Allow | allow property

Gets the HttpMethodHeaderValueCollection of HttpMethod objects that represent the value of an Allow HTTP header on an HTTP response.

Syntax


var allow = httpResponseHeaderCollection.allow;

public HttpMethodHeaderValueCollection Allow { get; }

Public ReadOnly Property Allow As HttpMethodHeaderValueCollection

public:
property HttpMethodHeaderValueCollection^ Allow { 
   HttpMethodHeaderValueCollection^ get();
}

Property value

Type: HttpMethodHeaderValueCollection

The collection of HttpMethod objects that represent the value of an Allow HTTP header on an HTTP response. An empty collection means that the header is absent.

Remarks

The Allow property represents the value of an Allow HTTP header on an HTTP response. The Allow header is a list of HTTP methods (GET, PUT, and POST, for example) allowed by the HTTP server.

The following sample code shows a method to get and set the Allow header on an HttpResponseMessage object using the Allow property on the HttpResponseHeaderCollection object.


    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());
    }

Requirements (Windows 10 device family)

Device family

Universal

API contract

Windows.Foundation.UniversalApiContract, introduced version 1.0

Namespace

Windows.Web.Http.Headers
Windows::Web::Http::Headers [C++]

Metadata

Windows.Foundation.UniversalApiContract.winmd

Requirements (Windows 8.x and Windows Phone 8.x)

Minimum supported client

Windows 8.1

Minimum supported server

Windows Server 2012 R2

Minimum supported phone

Windows Phone 8.1 [Windows Phone Silverlight 8.1 and Windows Runtime apps]

Namespace

Windows.Web.Http.Headers
Windows::Web::Http::Headers [C++]

Metadata

Windows.winmd

See also

HttpMethod
HttpMethodHeaderValueCollection
HttpResponseHeaderCollection
HttpResponseMessage
HttpResponseMessage.Headers