Which HttpClient class should I use for Universal apps? RRS feed

  • Question

  • Hi,

    I am developing a Windows Universal app for Windows phone and WinRT in C# and I would like to know which HttpClient class should i use? Should I use the System.Net.HttpClient or Windows.Web.HttpClient?

    • Moved by Fred Bao Tuesday, February 10, 2015 5:52 AM WinPhone Related
    Monday, February 9, 2015 4:40 PM


All replies

  • Use Windows.Web.HttpClient

    Tuesday, February 10, 2015 6:05 AM
  • Thanks Rob.

    May I ask why do you recommend Windows.Web.HttpClient?

    Isn't the System.Net.HttpClient portable between winRT and phone?

    Tuesday, February 10, 2015 2:19 PM
  • Because the System.Net.Http and System.Net.Http.Headers namespaces might not be available in future versions of Windows for use by Windows Store apps. It is stated in the official documentation on MSDN here:

    "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."

    And the Windows.Web.Http.HttpClient class is supported from Windows Phone 8.1, Windows 8.1 and Windows Server 2012 R2: https://msdn.microsoft.com/en-us/library/windows/apps/xaml/windows.web.http.httpclient.aspx

    Hope that helps.

    Please remember to close your threads by marking all helpful posts as answer and then start a new thread if you have a new question.

    Tuesday, February 10, 2015 2:55 PM