Share via


HttpClient Constructors

Definition

Overloads

HttpClient()

Initializes a new instance of the HttpClient class. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

HttpClient(IHttpFilter)

Initializes a new instance of the HttpClient class with a specific filter for handling HTTP response messages. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

HttpClient()

Initializes a new instance of the HttpClient class. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

public:
 HttpClient();
 HttpClient();
public HttpClient();
function HttpClient()
Public Sub New ()

See also

Applies to

HttpClient(IHttpFilter)

Initializes a new instance of the HttpClient class with a specific filter for handling HTTP response messages. For programming guidance for the HttpClient class, and code examples, see the HttpClient conceptual topic.

public:
 HttpClient(IHttpFilter ^ filter);
 HttpClient(IHttpFilter const& filter);
public HttpClient(IHttpFilter filter);
function HttpClient(filter)
Public Sub New (filter As IHttpFilter)

Parameters

filter
IHttpFilter

The HTTP filter to use for handling response messages.

Examples

The sample code shows creating an HttpClient to use a custom filter.

internal static void CreateHttpClient(ref HttpClient httpClient)
{
    if (httpClient != null) {
        httpClient.Dispose();
    }

    // HttpClient can be extended by plugging multiple filters together,
    // providing HttpClient with the configured filter pipeline.
    var baseFilter = new HttpBaseProtocolFilter();

    var myFilter = new MyCustomFilter(baseFilter);
    httpClient = new HttpClient(myFilter);
}

Remarks

If a null reference (Nothing in Visual Basic) is specified for the filter parameter, the default transport handler for receiving responses with no filter is used.

See also

Applies to