IHttpFilter.SendRequestAsync method

Applies to Windows and Windows Phone

Send an HTTP request on the IHttpFilter instance as an asynchronous operation.


IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress> SendRequestAsync(
  HttpRequestMessage request



Type: HttpRequestMessage

The HTTP request message to send.

Return value

Type: IAsyncOperationWithProgress<HttpResponseMessage, HttpProgress>

The object representing the asynchronous operation.


A number of exceptions can occur when calling this method. Only a few of the possible errors that can cause exceptions are listed.

You must write code to handle exceptions when you call this method. Exceptions can result from parameter validation errors, name resolutions failures, and network errors. Exceptions from network errors (loss of connectivity, connection failures, and HTTP server failures, for example) can happen at any time. These errors result in exceptions being thrown. If not handled by your app, an exception can cause your entire app to be terminated by the runtime.

An app can use the HRESULT from the exception to learn more detailed information on the error that caused the exception.

For more information on possible exceptions and how to handle exceptions, see Handling exceptions in network apps.


The request parameter was a null reference (Nothing in Visual Basic).


The request message was already sent by the IHttpFilter instance.


Custom filters are implemented in the SendRequestAsync method on their IHttpFilter interface.

Classes in the Windows.Web.Http namespace support the use of filters based on the classes in the Windows.Web.Http.Filters namespace. The HttpClient class in the Windows.Web.Http namespace provides a base class for sending HTTP requests and receiving HTTP responses. Filters provide a handler mechanism to help with common HTTP service issues. Simple filters can be chained together in a sequence to handle more complex HTTP service issues.

An HTTP filter is a black box which takes an HTTP request message and produces an HTTP response message. How the filter gets an HTTP response is determined by the filter developer. An app can create the response immediately, it can send the request over TCP to a server, it can even send multiple requests to a server (or to more than one server) before it generates a response message. Since it is unspecified how a filter gets to a response message, a filter can pass the request message to another filter (called the inner filter), thus delegating the creation of a response message to the inner filter.

Filters commonly add or change headers, handle authorization (possibly using the WebAuthenticationBroker), or allow or disallow a request based on network conditions. Filters usually make changes and then pass the request to an inner filter, which is typically set when a filter is constructed.

This approach allows filters to be only responsible for a specific aspect of an HTTP request execution and delegate other aspects to other filters. A filter can implement caching, authentication, redirects, cookies, actual communication with the server, or a combination of these. The bottom-most (base) filter will usually be the one that does actual communication with the network.


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]


Windows::Web::Http::Filters [C++]



See also




© 2014 Microsoft