Which Httpclient is better in WinRT development?

2019-09-02 20:45发布

In my progress of winRt development i find that I can use both of the two HttpClient:

System.Net.Http.HttpClient
windows.web.http.httpclient

What's the difference and how can i choose one?

2条回答
Rolldiameter
2楼-- · 2019-09-02 20:59

#1 is a .net function so it can only be used from .net languages (C# and VB.net), while #2 is from the Windows Runtime which means it can also be used from javascript store apps.

If you're using C# use whatever you like. My guess is #1 is calling #2

查看更多
地球回转人心会变
3楼-- · 2019-09-02 21:02

You should be using

windows.web.http.httpclient

for WinRT development as stated here.

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 Runtime apps.

Here is the link from msdn.

查看更多
登录 后发表回答