Which Httpclient is better in WinRT development?

元气小坏坏 提交于 2019-12-13 05:14:38

问题


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?


回答1:


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.




回答2:


#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



来源:https://stackoverflow.com/questions/25173792/which-httpclient-is-better-in-winrt-development

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!