Information
The topic you requested is included in another documentation set. For convenience, it's displayed below. Choose Switch to see the topic in its original location.

HttpResponseHeaderCollection.Allow | allow property

Applies to Windows and Windows Phone

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

Syntax


var allow = httpResponseHeaderCollection.allow;

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

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

 

 

Show:
© 2014 Microsoft