Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
296 views
in Technique[技术] by (71.8m points)

c# - System.Net.Http.HttpClient vs Windows.Web.Http.HttpClient - What are the main differences?

When developing .NET 4.5 desktop apps for Windows I have been used to use System.Net.Http.HttpClient for all communication with a backend Web API. I am now developing a Windows Store app and has noticed the existence of Windows.Web.Http.HttpClient. I have looked for information on what the main differences are between the two clients but without any luck.

From MSDN I know that I should start using Windows.Web.Http.HttpClient in my Windows Store app since System.Net.Http.HttpClient might be removed from the API:

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.

But apart from this information, I have a hard time figuring out what are the main differences and what is the main benefit of using Windows.Web.Http.HttpClient? What does it add that we don't already got in System.Net.Http.HttpClient?

Answers backed by official documentation are greatly appreciated.

question from:https://stackoverflow.com/questions/31291008/system-net-http-httpclient-vs-windows-web-http-httpclient-what-are-the-main-di

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

There is not much to find about it. Some things that come in my mind:

  • The new API doesn't have dependencies to some low-level Windows functions, like the current API does.
  • The new API is better capable handling new methods related to the HTTP protocol, like WebSockets, etc.

Some useful information can be found in this blog post which also referenced this Build video. They speak about better cache control, and a way to add filters for authentication, easy access to cookies, reconnecting, etc.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...