Connecting to an HTTP server using System.Net.Http.HttpClient (Windows Store apps using C#/VB and XAML)

[This article is for Windows 8.x and Windows Phone 8.x developers writing Windows Runtime apps. If you’re developing for Windows 10, see the latest documentation]

Use System.Net.Http.HttpClient to connect to a web service using C# or Visual Basic in a Windows Store app.

Note  

The System.Net.Http and System.Net.Http.Headers namespace might not be available in future versions of Windows for use by Windows Store apps. Starting with Windows 8.1 and Windows Server 2012 R2, use Windows.Web.Http.HttpClient in the Windows.Web.Http namespace and the related Windows.Web.Http.Headers and Windows.Web.Http.Filters namespaces instead for Windows Store apps.

For desktop apps, the System.Net.Http and System.Net.Http.Headers namespaces are still recommended and will be available in future versions of Windows.

 

Developer Audience

Developers using C# or Visual Basic and XAML interested in creating Windows Store apps that connect to a web service.

The information in these topics apply to Windows Store apps written in C# or Visual Basic and XAML on Windows 8 or Windows Server 2012.

For more information on how to connect to a web service for Windows Runtime apps written in C# or Visual Basic and XAML on Windows 8.1, Windows Phone 8.1, and Windows Server 2012 R2, see How to connect to an HTTP server using Windows.Web.Http.HttpClient.

For more information on how to connect to a web service for Windows Runtime apps written in JavaScript and HTML, see Connecting to web services (HTML).

In this section

Topic Description

How to connect using System.Net.Http.HttpClient

Use the HttpClient class in the System.Net.Http namespace to send a GET request to a web service and retrieve the response.

How to use System.Net.Http.HttpClient handlers

Use the System.Net.Http.HttpClientHandler class with the System.Net.Http.HttpClient class in the System.Net.Http namespace to send a GET request to a web service and retrieve the response.

How to secure System.Net.Http.HttpClient connections

Secure System.Net.Http.HttpClient connections to a web service.

 

Other resources

Connecting to web services

How to configure network capabilities

How to enable loopback and debug network isolation

Reference

System.Net.Http

System.Net.Http.Headers

Windows.Web.Http

Windows.Web.Http.Filters

Windows.Web.Http.Headers

Samples

HttpClient Sample